mcp-server-builder
AGENTS.md0 starsChanged 2 months agoMITView on GitHub
This document is for AI agents (Claude Code, other LLMs, and human-directed coding assistants) working in the MCP Server Builder codebase. It reflects the actual, current implementation contract in docs/superpowers/plans/2026-09-07-mcp-server-builder-contract.md — read that file first for exact function signatures if you're modifying a service. MCP Server Builder turns an API/documentation URL into a complete, runnable MCP (Model Context Protocol) server. Pipeline: Built by: Muhammad Sami Asghar Mughal (Senior AI Agent Engineer, COO at MARSA Empower).
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 32,671 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository9 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ckm:banner-designSkill
- ckm:brandSkill
- ckm:design-systemSkill
- skill-creator-proSkill
- skill-creatorSkill
- ckm:slidesSkill
- ckm:ui-stylingSkill
- ui-ux-pro-maxSkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 103
SSRF protection lives in one place: All outbound HTTP fetches of user-supplied URLs MUST go through …
- Very specific: line 118
If there's no match, the tool is dropped and recorded in ignored_endpoints — it is never silently invented.
≈ “Common” is an estimate: at least 1 in 5 of the 41,581 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md – Instructions for AI Coding Agents
This document is for AI agents (Claude Code, other LLMs, and human-directed coding assistants)
working in the MCP Server Builder codebase. It reflects the actual, current implementation
contract in docs/superpowers/plans/2026-09-07-mcp-server-builder-contract.md — read that file
first for exact function signatures if you're modifying a service.
What this project is
MCP Server Builder turns an API/documentation URL into a complete, runnable MCP (Model Context Protocol) server. Pipeline:
URL → discover → analyze → design-tools (AI) → generate → validate → downloadBuilt by: Muhammad Sami Asghar Mughal (Senior AI Agent Engineer, COO at MARSA Empower).
Architecture at a glance
Frontend (Jinja2 templates + Tailwind CDN + vanilla JS)
↓ fetch() calls to /api/*
FastAPI Backend (app/main.py + app/routes/*)
├─ URL Validation & SSRF Protection (app/services/url_fetcher.py)
├─ API Discovery (app/services/api_discovery.py)
├─ OpenAPI/Swagger Parsing (app/services/openapi_parser.py)
├─ HTML Documentation Parsing (app/services/documentation_parser.py)
├─ API Normalization/Analysis (app/services/api_analyzer.py)
├─ OpenAI Access (centralized) (app/services/openai_service.py)
├─ AI-Driven MCP Tool Design (app/services/mcp_designer.py)
├─ Code Generation (Jinja2) (app/services/mcp_generator.py, app/templates/mcp_project/*.jinja)
├─ Generated-Server Validation (app/services/validator.py)
└─ Project Storage (JSON files + zips) (app/services/project_store.py)
↓
Generated MCP Servers (complete, runnable Python projects under generated-projects/{id}/)Repository layout (app/)
app/
├── main.py # FastAPI app, CORS, static mount, routers, /health
├── config.py # env vars, SSRF blocklists, thresholds, paths
├── models/
│ ├── api.py # APIRepresentation, Endpoint, Parameter, SecurityScheme, DiscoveryResult, enums
│ ├── mcp.py # MCPTool, MCPServerDesign, GeneratedMCPServer, ValidationResult, MCPProject
│ └── project.py # ProjectMetadata, ProjectSummary, HistoryResponse
├── services/
│ ├── url_fetcher.py # SSRF-safe fetch — safe_fetch(), validate_url_format()
│ ├── api_discovery.py # discover_api(url) -> DiscoveryResult
│ ├── openapi_parser.py # parse_openapi(), detect_spec_version()
│ ├── documentation_parser.py # parse_html_documentation() — best-effort HTML extraction
│ ├── api_analyzer.py # normalize_api(), detect_authentication(), summarize_for_ai()
│ ├── openai_service.py # call_structured() — the ONLY file that imports `openai`
│ ├── mcp_designer.py # design_tools(), build_demo_design()
│ ├── mcp_generator.py # generate_server(), render_mcp_client_config(), render_readme()
│ ├── validator.py # validate_generated_server()
│ └── project_store.py # create/save/load/list/delete_project, build_zip()
├── routes/
│ ├── pages.py # GET /, /builder, /history, /project/{id}
│ ├── analysis.py # POST /api/discover, /api/analyze, /api/design-tools
│ ├── generation.py # POST /api/generate, /api/validate, /api/regenerate
│ ├── projects.py # GET/DELETE /api/project/{id}, /api/history, feedback
│ └── downloads.py # GET /api/project/{id}/download, /api/project/{id}/file
├── templates/ # Jinja2 page templates + mcp_project/*.jinja code-gen templates
├── static/
│ ├── js/ # app.js, builder.js, history.js, project.js
│ ├── css/styles.css
│ ├── robots.txt, sitemap.xml
└── data/
├── demo_openapi.json # fixture "Task Manager API" (8 endpoints, bearer auth) for Demo Mode/tests
└── projects/ # one JSON file per MCPProject, {project_id}.json
generated-projects/ # generated server files + zips live here, NOT in app/data
tests/ # pytest suite (see docs/TESTING.md)How to run
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # add OPENAI_API_KEY (optional — Demo Mode works without it)
uvicorn app.main:app --reload --port 8000Open http://localhost:8000.
How to test
pytest # full suite (respx-mocked HTTP, no real network calls, no real OpenAI calls)
pytest --cov=app # with coverage
pytest tests/test_security.py -vSee docs/TESTING.md for what each test file covers.
Critical rules for anyone editing this codebase
- SSRF protection lives in one place. All outbound HTTP fetches of user-supplied URLs MUST
go through
app/services/url_fetcher.py::safe_fetch(). Never callhttpx.get/requests.getdirectly on user input anywhere else. It resolves hostnames viasocket.getaddrinfoand rejects any resolved address inconfig.BLOCKED_NETWORKS(DNS-rebinding safe), disables httpx's automatic redirects and manually re-validates every hop, caps response size, and restrictsContent-Type. Seedocs/SECURITY.mdfor the full threat model. - OpenAI access is centralized.
app/services/openai_service.pyis the ONLY file in the codebase that imports theopenaipackage. All AI calls go throughcall_structured(system_prompt, user_prompt, response_model), which returns a validated Pydantic model or raisesOpenAIServiceError— never a raw SDK exception. - Anti-hallucination rule — every MCP tool must trace to a real endpoint.
mcp_designer.pyasks the model to propose tools, but it never trusts the model'smethod/pathverbatim: every proposed tool is cross-validated againstapi.endpointsby(method.upper(), path). If there's no match, the tool is dropped and recorded inignored_endpoints— it is never silently invented. The same discipline applies everywhere else in the pipeline: never fabricate endpoints, parameters, or auth schemes that weren't actually discovered. If something can't be verified, mark it unknown or omit it. - Never log or embed secrets. API keys/tokens are never logged, and generated MCP servers read credentials from environment variables only — never hardcoded.
- No comments explaining what code does — only non-obvious why comments, sparingly.
- Async I/O throughout the request path —
httpx.AsyncClient,async defroutes/services. - Never leak internals to clients. Routes catch service exceptions and return a clean
detailmessage with an appropriate status code; a global exception handler inapp/main.pyturns any uncaught exception into{"detail": "Internal error"}while logging the real traceback server-side.
Storage model
Projects are JSON files, not a database: config.PROJECTS_DIR / f"{project_id}.json", one file
per MCPProject (model_dump(mode="json")). Generated server files are written to
config.GENERATED_DIR / project_id / <relative path>, and downloads are built as a fresh zip
per request (project_store.build_zip). Nothing is kept in memory between requests — every route
loads/saves through project_store.
Where to look for more detail
docs/ARCHITECTURE.md— per-service responsibilities and the full request/response flow.docs/SECURITY.md— SSRF threat model in depth.docs/DEPLOYMENT.md— dev vs. prod run commands, required env vars.docs/TESTING.md— test suite layout and how to add coverage.docs/superpowers/plans/2026-09-07-mcp-server-builder-contract.md— the authoritative interface contract (exact function signatures) for this build.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

