feat: MCP server over the pattern catalog - #10
Merged
Conversation
src/design_patterns_mcp/: MCPServer (mcp 2.x SDK) exposing - tools: list_patterns, get_pattern, search_patterns, run_example (sandboxed), recommend_pattern (caveats + prefer-alternative notes) - resources: catalog://index, pattern://<group>/<slug>[/<variant>] - prompts: refactor_toward, explain_pattern, choose_pattern search.py: pure-stdlib BM25 over frontmatter+prose with field weights. sandbox.py: catalog-resolved paths only, python -I subprocess, scrubbed env, temp cwd, 10s timeout, 64KB output caps. Console script python-design-patterns-mcp (stdio default, --http for Streamable HTTP). docs/mcp.md documents connection and the sandbox contract. 228 tests incl. in-memory MCP client integration and sandbox refusal tests; both transports probed live with initialize round-trips. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 10.
uv run python-design-patterns-mcpserves the catalog over MCP.Tools —
list_patterns·get_pattern(prose + source) ·search_patterns(pure-stdlib BM25) ·run_example(sandboxed subprocess, real stdout) ·recommend_pattern(caveats attached;prefer-alternativeverdicts point at the pythonic alternative)Resources —
catalog://index,pattern://<group>/<slug>,pattern://<group>/<slug>/<variant>Prompts —
refactor_toward,explain_pattern,choose_patternSandbox contract: only catalog-resolved files run —
(id, variant)is a dict lookup, never a path join;python -I, scrubbed env, temp cwd, 10s timeout, 64KB caps. Traversal-shaped ids/variants are refused (tested).Verified: 228 tests (incl. in-memory MCP
Clientintegration); stdio and Streamable HTTP both answeredinitializeround-trips live. Dep:mcp(2.x SDK). Console script wired inpyproject.toml;docs/mcp.mdhasclaude mcp addconfig.🤖 Generated with Claude Code