API & MCP

Retrieve contexts programmatically

ContextRail delivers standards to AI tools over the Model Context Protocol (MCP). Four focused tools give your AI everything it needs — from keyword search to full dependency resolution.

MCP tools

Use these tools in order for efficient, token-aware context retrieval.

search_contexts

Find contexts by keyword, tag, or domain. Use this first for targeted discovery.

Searching before retrieving — conserves token budget with lightweight summaries.

get_context

Retrieve a full context by ID — imperatives, examples, checklist, and dependencies.

After discovering a relevant context via search, fetch the complete standard.

list_contexts

Browse all available contexts for broad exploration.

Use only when search fails — returns all contexts with summary-level detail.

resolve_dependencies

Fetch the full dependency graph for a set of context IDs.

After retrieving a context, pull all related standards automatically.

How it fits together

Every context request flows through the MCP server to MongoDB and back to your AI tool.

1
AI ToolCursor, Claude, Copilot
2
MCP RequestTool call over HTTP
3
ContextRail APIExpress / Node.js
4
MongoDBOrg-scoped storage
5
ResponseStandards delivered

Recommended usage order

Follow this sequence to retrieve standards efficiently and completely.

01
Search first

Call search_contexts with a plain-text query. Returns lightweight summaries to conserve your token budget — only fetch full content when needed.

02
Retrieve full context

Call get_context for each relevant context ID returned by search. This gives you imperatives, examples, and checklists.

03
Resolve dependencies

Call resolve_dependencies on selected context IDs to pull related standards automatically. Prevents missing linked requirements.

04
Apply and validate

Use the retrieved standards as non-functional requirements in your implementation. Validate code changes against all applicable imperatives.

REST API reference
  • The full REST API is documented at /docs on your deployed API server (Swagger UI).
  • Use the REST API for context management, user administration, and billing — not for day-to-day standards retrieval.
  • For AI tool integrations, prefer MCP tools over direct REST calls — MCP is optimized for token-efficient, structured retrieval.