Mcp builder
Build or extend a GenericSuite MCP server that exposes the app's AI tools (the *_func companions generated by python-ai-tools-code-builder) and optionally CRUD entities as MCP tools, with authentication, prompts and Claude Desktop / VS Code client configs. Use when the user wants their GenericSuite backend reachable from MCP clients. Re-runnable: adds wrappers for new tools without duplicating existing ones.From its SKILL.md
npx -y skills add tomkat-cr/genericsuite-skills --skill mcp-builderAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.9 KB, as published. Nobody here has run it
Build the project's MCP server, following the canonical patterns bundled
under references/:
references/mcp_server_full_example.py— exampleapp's complete server (auth tools, many tool wrappers, prompts, resources)references/mcp_server_minimal.py— fastapitemplate's minimal starterreferences/mcp-server-package.json,references/mcp-server-README.md— mcp-server directory scaffoldingreferences/claude_desktop_{stdio,http}_config.json,references/vscode_mcp_{stdio,http}_config.json— client config STRUCTURE only. WARNING: these carry stalegenericsuite-codegennames/paths from an earlier template — always generate configs with the TARGET app's own name, paths and env var names.
READ the reference files before generating. Conventions:
- The server is built with
genericsuite.mcplib.util.create_app.create_app(app_name=..., settings=..., log_file=...);mcp = app.mcp. - Every app AI tool is wrapped as an async
@mcp.tool()that: declares TYPED parameters (not a params dict — MCP clients need the schema), callsverify_app_context(app, cac_object_list), delegates to the tool's<name>_func({...}), and returnstool_result(result)(optionally with a metadata dict). cac_object_listcollects thecacobject imported from EVERY tool module (from lib.models.ai_chatbot.ai_gpt_fn_<domain> import cac as cac_<domain>).- Standard auth block always present:
get_api_keys()tool exposingGS_USER_ID/GS_USER_NAME/GS_API_KEYenv vars, anauthentication_tool(username, password)usingmcp_authenticate(app, cac_object_list, username, password)/verify_app_context, and theuser://login/{username}/{password}resource. - If a tool module exports prompt functions, wrap each as
@mcp.prompt("<name>"). - Entry point:
def main(): app.run()guarded byif __name__ == "__main__":.
Step 1 — Gather inputs
- Project root (where
lib/lives) and the mcp-server location:server/lib/mcp_server.pyfor fastapitemplate-style single-package projects, or a siblingmcp-server/mcp_server.pydirectory for exampleapp-style monorepos (then scaffold the directory). - Tool modules: scan
lib/models/ai_chatbot/ai_gpt_fn_*.py(excludingai_gpt_fn_index.py) and list every<name>_func; confirm with the user which to expose (default: all). - CRUD entities (optional): which entries from
config_dbdef/backend/endpoints.jsonto expose as list/get/create/ update/delete MCP tools (default: none). - Existing server? If
mcp_server.pyexists, operate in EXTEND mode: only add missing imports,cac_<domain>entries and@mcp.tool()wrappers — never duplicate a wrapper whose function name already exists, never reorder existing code.
Step 2 — Generate or extend mcp_server.py
New-server skeleton (adapt names; wrappers per Step 3):
#!/usr/bin/env python3
"""
MCP Server
A Model Context Protocol server that exposes <app_name>'s
tools to AI clients.
"""
from typing import Dict, Any
import os
from genericsuite.util.app_logger import log_info
from genericsuite.mcplib.util.create_app import create_app
from genericsuite.mcplib.util.utilities import (
mcp_authenticate,
verify_app_context,
tool_result,
)
from lib.config.config import Config
from lib.models.ai_chatbot.ai_gpt_fn_<domain> import (
cac as cac_<domain>,
<tool_name>_func,
)
DEBUG = False
settings = Config()
app = create_app(app_name=f'{settings.APP_NAME.lower()}-mcp-server',
settings=settings, log_file='./logs/mcp_server.log')
mcp = app.mcp
cac_object_list = [cac_<domain>]
@mcp.tool()
async def get_api_keys() -> Dict[str, Any]:
"""
Get API keys
"""
_ = DEBUG and log_info("Getting API keys")
return {
"resultset": {
"GS_USER_ID": os.environ.get("GS_USER_ID"),
"GS_USER_NAME": os.environ.get("GS_USER_NAME"),
"GS_API_KEY": os.environ.get("GS_API_KEY")
}
}
@mcp.tool()
async def authentication_tool(
username: str,
password: str,
) -> str:
"""
Authenticate user
"""
_ = DEBUG and log_info("Authenticating user")
if not username and not password:
if verify_app_context(app, cac_object_list):
return tool_result("User already authenticated with API key")
return tool_result("Username and password are required")
return mcp_authenticate(app, cac_object_list, username, password)
@mcp.resource("user://login/{username}/{password}",
mime_type="application/json")
async def authenticate(
username: str,
password: str,
) -> str:
"""
Get user login as a resource
"""
return mcp_authenticate(app, cac_object_list, username, password)
# <tool wrappers go here — one per exposed *_func, see Step 3>
def main():
"""
Main entry point for the MCP Server
"""
print(f"Starting {settings.APP_NAME} MCP Server...")
app.run()
if __name__ == "__main__":
main()
Step 3 — Tool wrappers
One wrapper per exposed _func, with typed parameters mirroring the
tool's Pydantic schema (required params first, optional ones with
defaults):
@mcp.tool()
async def <tool_name>(
<param>: <type>,
<optional_param>: <type> = <default>,
) -> Dict[str, Any]:
"""
<Docstring the MCP client shows — copy the tool's purpose line.>
"""
_ = DEBUG and log_info(f"<tool_name>: {<param>}")
verify_app_context(app, cac_object_list)
result = <tool_name>_func({
"<param>": <param>,
"<optional_param>": <optional_param>,
})
return tool_result(result)
Prompt functions (when the tool module exports them):
@mcp.prompt("<prompt_name>")
async def <prompt_name>_prompt(
<param>: str = "<default>",
) -> str:
"""
<What the prompt template is for.>
"""
verify_app_context(app, cac_object_list)
return <prompt_name>_prompt_func(<param>=<param>)
Optional CRUD wrappers (per selected entity, delegating to the
GenericSuite DB middleware through a _func-style helper the skill also
generates in lib/models/ai_chatbot/ai_gpt_fn_<entity>_crud.py following
the python-ai-tools-code-builder conventions) — only when the user asked
for CRUD exposure in Step 1.
Step 4 — Scaffolding (new mcp-server directory only)
When creating a sibling mcp-server/ directory, also generate:
package.json— adaptreferences/mcp-server-package.json, replacing the app name/repo URLs with the target app's.- Client configs —
claude_desktop_stdio_config.json,claude_desktop_http_config.json,vscode_mcp_stdio_config.json,vscode_mcp_http_config.json— same JSON structure as the references but with the target app's server name, absolute-path placeholder (/absolute/path/to/<app>/mcp-server/run_mcp_server.sh) andMCP_API_KEY=<your-api-key>placeholder. README.md— adaptreferences/mcp-server-README.mdrun instructions.
Step 5 — Verify and summarize
python3 -m py_compile mcp_server.py— exit 0.- Cross-check: every exposed
_funchas exactly ONE@mcp.tool()wrapper; every imported tool module'scacis incac_object_list; generated JSON configs parse (python3 -c "import json, ..."). - In EXTEND mode: diff summary — wrappers added vs. skipped as already present.
- Summarize files created, how to run (
python3 mcp_server.pyor the package.json scripts), and where to paste the client configs.