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.
Find contexts by keyword, tag, or domain. Use this first for targeted discovery.
Searching before retrieving — conserves token budget with lightweight summaries.
Retrieve a full context by ID — imperatives, examples, checklist, and dependencies.
After discovering a relevant context via search, fetch the complete standard.
Browse all available contexts for broad exploration.
Use only when search fails — returns all contexts with summary-level detail.
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.
Recommended usage order
Follow this sequence to retrieve standards efficiently and completely.
Call search_contexts with a plain-text query. Returns lightweight summaries to conserve your token budget — only fetch full content when needed.
Call get_context for each relevant context ID returned by search. This gives you imperatives, examples, and checklists.
Call resolve_dependencies on selected context IDs to pull related standards automatically. Prevents missing linked requirements.
Use the retrieved standards as non-functional requirements in your implementation. Validate code changes against all applicable imperatives.
- 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.