MCP Server
Estimated reading time: 6 minutes 预计阅读时间: 6 分钟summer-mcp is the engineering entrypoint for AI tools in Summerrs Admin. Built on rmcp, it exposes database schemas, generic table tools, code generators, and menu/dictionary business tools to MCP-capable clients.
The main app registers it in crates/app/src/main.rs:
McpPlugin depends on SeaOrmPlugin. On startup it:
- Reads
[mcp]config. - Checks
enabled. - Gets
DatabaseConnection. - Verifies the database backend is PostgreSQL.
- Chooses embedded routing or standalone startup based on
transportandhttp_mode.
Config
Development and production environments can enable MCP through [mcp]:
The default Host allowlist in code is:
Use allowed_hosts and allowed_origins to tighten HTTP access sources. Do not expose MCP directly to the public internet in production.
Run Modes
In the default embedded HTTP mode, path = "/mcp". If the web layer also has a global prefix, the final path includes that prefix; otherwise it is /mcp on the main app. System business APIs are mounted under /api, while MCP serves MCP clients.
Standalone binary example:
stdio mode is useful for local AI tools connecting through a subprocess:
Capability Overview
Call server_capabilities when a client first connects. It returns:
This is a runtime snapshot for AI clients and is more reliable than making the client guess which tools are available.
Resources
AdminMcpServer publishes one resource and one resource template:
Recommended workflow:
Do not let AI guess field names without reading schema first.
Generic Table Tools
summer-mcp/src/table_tools/router.rs provides generic CRUD:
These tools target PostgreSQL by default. Many parameters support explicit schema; when a schema is provided, tools either set search_path inside the transaction or generate schema-qualified SQL.
SQL Tools
MCP also provides two SQL escape hatches:
sql_query_readonly normalizes user SQL into a read-only subquery and adds a limit. sql_exec is for explicit writes or DDL and should not be used for ordinary reads.
Both are riskier than table tools. Recommended priority:
Code Generation Tools
Backend generators:
Frontend generators:
generator_capability_catalog declares two target presets:
Generation tools support temporary output directories. Prefer outputting to /tmp/... first, review the generated files, then move them into the target project.
Menu And Dictionary Tools
Manage menus and dictionaries through MCP business tools instead of asking AI to write SQL against tree structures and enum data:
Recommended flow:
This is less likely to break tree structure, sort order, permission identifiers, and dictionary constraints than hand-written SQL.
Prompt Templates
The MCP Server publishes three prompts:
If the client supports MCP prompts, prefer them. They reduce the chance that AI skips resource reads and guesses structure.
Security Boundary
MCP is a development and operations tool, not a tenant-user API.
Deployment notes:
- Only PostgreSQL is supported; non-PostgreSQL backends fail at startup.
- Embedded HTTP runs in the same process as the main app, but it does not automatically inherit
summer-systemJWT/RBAC. - Standalone mode binds to
127.0.0.1:9090by default; do not casually change it to0.0.0.0. sql_execcan execute DDL/DML and should only be available in trusted environments.- Production should configure Host/Origin allowlists and restrict access with the network layer or reverse proxy.
- In multi-tenant scenarios, MCP sees the real database structure and should not be exposed as a normal tenant tool.
Relationship To The System Backend
MCP shares the database connection with the system backend and also reuses menu and dictionary domain services from summer-domain. But MCP itself is not a normal business endpoint under summer-system/src/router.
The system backend provides human-facing admin UI and APIs. MCP gives AI tools a structured and controlled engineering entrypoint.
