agentsclimarketplace

Mcp builder

Skill tomkat-cr/genericsuite-skills/skills/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

Install
npx -y skills add tomkat-cr/genericsuite-skills --skill mcp-builder

Assembled 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 starter
  • references/mcp-server-package.json, references/mcp-server-README.md — mcp-server directory scaffolding
  • references/claude_desktop_{stdio,http}_config.json, references/vscode_mcp_{stdio,http}_config.json — client config STRUCTURE only. WARNING: these carry stale genericsuite-codegen names/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:

  1. The server is built with genericsuite.mcplib.util.create_app.create_app(app_name=..., settings=..., log_file=...); mcp = app.mcp.
  2. Every app AI tool is wrapped as an async @mcp.tool() that: declares TYPED parameters (not a params dict — MCP clients need the schema), calls verify_app_context(app, cac_object_list), delegates to the tool's <name>_func({...}), and returns tool_result(result) (optionally with a metadata dict).
  3. cac_object_list collects the cac object imported from EVERY tool module (from lib.models.ai_chatbot.ai_gpt_fn_<domain> import cac as cac_<domain>).
  4. Standard auth block always present: get_api_keys() tool exposing GS_USER_ID/GS_USER_NAME/GS_API_KEY env vars, an authentication_tool(username, password) using mcp_authenticate(app, cac_object_list, username, password) / verify_app_context, and the user://login/{username}/{password} resource.
  5. If a tool module exports prompt functions, wrap each as @mcp.prompt("<name>").
  6. Entry point: def main(): app.run() guarded by if __name__ == "__main__":.

Step 1 — Gather inputs

  1. Project root (where lib/ lives) and the mcp-server location: server/lib/mcp_server.py for fastapitemplate-style single-package projects, or a sibling mcp-server/mcp_server.py directory for exampleapp-style monorepos (then scaffold the directory).
  2. Tool modules: scan lib/models/ai_chatbot/ai_gpt_fn_*.py (excluding ai_gpt_fn_index.py) and list every <name>_func; confirm with the user which to expose (default: all).
  3. CRUD entities (optional): which entries from config_dbdef/backend/endpoints.json to expose as list/get/create/ update/delete MCP tools (default: none).
  4. Existing server? If mcp_server.py exists, 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 — adapt references/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) and MCP_API_KEY=<your-api-key> placeholder.
  • README.md — adapt references/mcp-server-README.md run instructions.

Step 5 — Verify and summarize

  1. python3 -m py_compile mcp_server.py — exit 0.
  2. Cross-check: every exposed _func has exactly ONE @mcp.tool() wrapper; every imported tool module's cac is in cac_object_list; generated JSON configs parse (python3 -c "import json, ...").
  3. In EXTEND mode: diff summary — wrappers added vs. skipped as already present.
  4. Summarize files created, how to run (python3 mcp_server.py or the package.json scripts), and where to paste the client configs.

Keep looking

Skills are one crate of 608,475. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.