Skip to content

feat: MCP server over the pattern catalog - #10

Merged
SuperElectron merged 1 commit into
stagingfrom
feat/mcp-server
Aug 27, 2026
Merged

feat: MCP server over the pattern catalog#10
SuperElectron merged 1 commit into
stagingfrom
feat/mcp-server

Conversation

@SuperElectron

Copy link
Copy Markdown
Owner

Phase 10. uv run python-design-patterns-mcp serves the catalog over MCP.

Toolslist_patterns · get_pattern (prose + source) · search_patterns (pure-stdlib BM25) · run_example (sandboxed subprocess, real stdout) · recommend_pattern (caveats attached; prefer-alternative verdicts point at the pythonic alternative)

Resourcescatalog://index, pattern://<group>/<slug>, pattern://<group>/<slug>/<variant>
Promptsrefactor_toward, explain_pattern, choose_pattern

Sandbox 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 Client integration); stdio and Streamable HTTP both answered initialize round-trips live. Dep: mcp (2.x SDK). Console script wired in pyproject.toml; docs/mcp.md has claude mcp add config.

🤖 Generated with Claude Code

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>
@SuperElectron
SuperElectron merged commit b9f7fbe into staging Aug 27, 2026
3 checks passed
@SuperElectron
SuperElectron deleted the feat/mcp-server branch August 27, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant