01
Problem
AI coding assistants lack domain-specific knowledge about framework best practices. When building LangGraph agents, developers must repeatedly explain patterns, copy-paste from docs, or watch the AI reinvent suboptimal solutions. The assistant's training data is often outdated relative to fast-moving frameworks.
02
Solution
Use MCP (Model Context Protocol) servers to inject production patterns directly into the AI assistant's context:
- Create an MCP server that exposes domain patterns as tools and resources
- Structure patterns with clear signatures, descriptions, and code snippets
- Configure Claude Desktop or Cursor to connect to the MCP server
- The AI can now "call" patterns on-demand, getting current best practices
// Example: MCP tool that returns a LangGraph pattern
server.tool("get_pattern", { name: z.string() }, async ({ name }) => {
const pattern = PATTERNS[name];
return {
content: [{
type: "text",
text: `
03
How to use it
- Build MCP servers for any framework your team uses heavily (LangGraph, FastAPI, React patterns)
- Keep patterns small and focused—one pattern per tool call
- Include "when to use" and "when NOT to use" guidance in pattern descriptions
- Version your patterns alongside your codebase
- Use
npxfor easy distribution:npx your-patterns-mcp
04
Trade-offs
Pros: Always up-to-date patterns; on-demand retrieval saves context space; patterns are structured and tested.
Cons: Requires MCP server setup; adds latency for tool calls; patterns must be maintained.
06
References
- Model Context Protocol: https://modelcontextprotocol.io/
- LangGraph Patterns MCP (reference impl): https://github.com/Rajathbharadwaj/langgraph-patterns-mcp
- Claude Desktop MCP Integration: https://docs.anthropic.com/en/docs/claude-code/mcp
- Cursor MCP Support: https://docs.cursor.com/context/model-context-protocol