Production-minded Model Context Protocol server that exposes curated Cartesi developer resources — including repositories, documentation, articles, and skills — from PostgreSQL to AI agents over streamable HTTP.
- FastMCP (
mcp[cli]1.26.x) withstreamable_http_app()— FastMCP's Starlette app used directly in production so session lifespan runs correctly (seecreate_app()insrc/main.py). - Async SQLAlchemy + asyncpg for read-only access to the knowledge database.
- Layered layout: config and logging (
src/core/), DB session and models (src/db/), repositories, domain service (src/domain/resource_service.py), schemas, formatters, and server modules undersrc/server/. - Transport security: DNS rebinding protection and configurable
allowed_hosts/allowed_originsinsrc/server/server.py. - Plain HTTP health:
GET /healthreturns{"status":"ok"}alongside the MCP route.
| Resource type | Body delivery | Agent action needed |
|---|---|---|
| Skills | Inline — body stored in DB | Call get_skill(id) — no URL fetch |
| Articles | Inline — body stored in DB | Call get_article_content(id) — no URL fetch |
| Documentation | Metadata + external links | Fetch canonical_url / route url separately |
| Repositories | Metadata + external links | Fetch canonical_url separately |
Workflow tools (prepare_cartesi_*, send_input_to_application, prepare_*_deposit_instructions, get_cartesi_app_logic_guidance) return instructions and command templates for the user's machine. They do not run the Cartesi CLI or cast from this server.
1. summarize_knowledge_base → orientation (counts include skills + articles)
2. list_skills → check for a matching skill FIRST (body is inline)
└─ get_skill(resource_id) → read body directly — no URL fetch needed; stop here if sufficient
3. [No skill covers task] get_knowledge_taxonomy → discover valid tag/source filter values
4. search_knowledge_resources → find repos/docs/articles by query+tag+source+kind
└─ get_article_content(id) → article bodies are inline (no URL fetch needed)
5. fetch_resource_content(url) → for documentation/repository pages needing full body
Why skills first? Skills are purpose-built for agent consumption, their body is stored inline in the DB (zero external fetch latency), and they are curated validated procedures — more reliable than interpreting raw docs.
- Python ≥ 3.11 (see
pyproject.toml; the includedDockerfileuses Python 3.12). - PostgreSQL database with the schema managed by the
mcp-admin-server(includesresources,articles,skills,repositories,doc_routes,tags,sourcestables).
Copy .env.example to .env and adjust. Defaults and field names are in src/core/config.py (notably DATABASE_URL, APP_HOST, APP_PORT, MCP_BASE_URL, pagination limits, connection pool settings). For PostgreSQL URLs, postgres://... is normalized to postgresql+asyncpg://..., and sslmode is translated to asyncpg-compatible ssl.
Using uv (recommended):
uv syncUsing pip:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtpython -m src.mainuv run python -m src.mainuv run uvicorn src.main:create_app --factory --host 0.0.0.0 --port 8000The MCP endpoint is streamable HTTP at:
http://<host>:<port>/mcp(default:http://0.0.0.0:8000/mcp)
Multi-stage Dockerfile — installs deps with uv, runs python -m src.main. Set DATABASE_URL and other env vars at runtime (via -e or your orchestrator).
http://localhost:8000/mcp| URI | Purpose |
|---|---|
cartesi://health |
Server name, environment, MCP_BASE_URL, read-only flag, capabilities, content policy |
cartesi://resources |
Catalog: index of resource URIs, tool names, prompts, tool groups, and suggested agent flow |
cartesi://resources/{resource_id} |
Normalized resource metadata |
cartesi://docs/{resource_id} |
Documentation resource view |
cartesi://docs/routes/{route_id} |
Single doc route with parent context |
cartesi://repositories/{resource_id} |
Repository sync / freshness metadata |
cartesi://collections/tag/{tag} |
Resources grouped by tag |
cartesi://collections/source/{source} |
Resources grouped by source |
cartesi://skills |
List all available skills for discovery |
cartesi://skills/{resource_id} |
Skill body inline (no external fetch required) |
cartesi://articles/{resource_id} |
Article body inline (no external fetch required) |
summarize_knowledge_base— coverage counts (including skills/articles), orientation guide. Call this first.get_knowledge_taxonomy— canonical tag and source titles for filtering
list_skills— list all skills with title, description, tagsget_skill— full skill body returned inline, no URL fetch required
list_articles— list articles with optional tag/source filterget_article_content— full article body returned inline, no URL fetch required
search_knowledge_resources— search by query, tag, source, kind (repository,documentation,article,skill)search_documentation_routes— search routes across resourcesbuild_debugging_context— issue-focused bundle of resources and routes
get_resource_detail— one resource by ID, with optional routeslist_resource_doc_routes— routes for a documentation resourcelist_doc_route_sections— distinct section names for a documentation resourcelist_resources_for_tag/list_resources_for_sourceget_repository_sync_status
fetch_resource_content— fetch and return external URL body (docs.cartesi.io, github.com, etc.)
prepare_cartesi_create_command— stable v1.5.x vs alpha v2.0 create guidanceprepare_cartesi_build_commandprepare_cartesi_run_commandget_cartesi_app_logic_guidance— address-book, portals, vouchers, notices, reports
send_input_to_application— InputBox +casttemplatesprepare_erc20_deposit_instructions— ERC20Portal flowprepare_erc721_deposit_instructions— ERC721Portal flowprepare_erc1155_deposit_instructions— ERC1155SinglePortal flowprepare_eth_deposit_instructions— EtherPortal flowprepare_erc1155_batch_deposit_instructions— ERC1155BatchPortal flowprepare_voucher_execution_instructions— voucher execution with GraphQL proof query
debug_cartesi_issue— structured debugging using curated knowledgefind_cartesi_docs— doc route discovery for a topicexplain_repository_context— repository resource + status summary
- Agent-facing documentation, implementation tracker, and optimization plan live in
.agents/(git-ignored, local only). Start with.agents/INDEX.md. - Before adding a new tool or resource, read
.agents/MCP_CATALOG_MAINTENANCE.md— catalog entries must be kept in sync manually. - The
kindfield on resources:"repository","documentation","article","skill","resource".