mcp-server-build
Skill1 starsChanged 4 months agoMITView on GitHub
Use when the user wants to expose their tools, APIs, or data to an AI agent via the Model Context Protocol — building a new MCP server (tools/resources/prompts), choosing stdio vs HTTP transport, writing tool JSON Schemas, or connecting a built server to Hermes or another MCP client.
- Installs packages
In this repository58 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- api-test-suiteSkill
- ascii-artSkill
- caddy-reverse-proxySkill
- changelog-generatorSkill
- color-palette-generatorSkill
- cron-taskSkill
- csv-toolkitSkill
- discord-bot-buildSkill
- docker-umbrellaSkill
- dotfiles-manageSkill
- email-sendSkill
- env-config-managerSkill
- excalidraw-diagramSkill
- file-organizerSkill
- forgejo-self-hostSkill
- frontend-design-toolkitSkill
- generate-dockerfileSkill
- gif-searchSkill
- git-backupSkill
- github-actions-ciSkill
- hallmark-readmeSkill
- http-api-testerSkill
- invoice-generatorSkill
- json-formatterSkill
- log-analyzerSkill
- markdown-linterSkill
- markdown-to-pdfSkill
- markdown-to-slidesSkill
- media-id-mappingSkill
- movie-catalogue-siteSkill
- movie-night-calendarSkill
- ntfy-notifierSkill
- ocr-documentsSkill
- ollama-localSkill
- openapi-generatorSkill
- password-generatorSkill
- pdf-extractSkill
- portfolio-upkeepSkill
- qr-code-generatorSkill
- regex-testerSkill
- resume-builderSkill
- rss-monitorSkill
- searxng-self-hostSkill
- skill-publishSkill
- skill-registry-catalogSkill
- skills-portfolio-scaffoldSkill
- snippet-managerSkill
- sqlite-dashboardSkill
- streaming-provider-embedsSkill
- tailscale-deploySkill
- telegram-bot-buildSkill
- tmdb-metadataSkill
- uptime-kuma-self-hostSkill
- watchlist-syncSkill
- webhook-receiverSkill
- youtube-transcriptSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 140
Every tool needs a clear JSON Schema so the agent knows what arguments to pass:
- Distinctive: line 239
Forgetting the session is cached: After adding a new tool to a running server, some MCP clients (including Hermes) cache the tool list from …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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
mcp-server-build
Overview
Build a Model Context Protocol (MCP) server that exposes your tools, resources, and prompts to AI agents. MCP is an open protocol that lets AI assistants interact with external systems through a standardized interface.
When to Use
- The user wants to expose their tools or APIs to an AI agent via MCP.
- The user wants to build an MCP server for a custom service.
- The user says "build an MCP server", "make my tool work with MCP", or "I want my agent to call my API".
MCP Protocol Basics
MCP servers expose three types of capabilities:
| Capability | What it does |
| Tools | Functions the agent can call (e.g., search_database, send_email) |
| Resources | Data the agent can read (e.g., file://config.json, db://schema) |
| Prompts | Pre-built prompt templates the agent can use |
Servers communicate via JSON-RPC over one of two transports:
| Transport | Use case |
| stdio | Local servers, launched by the agent process |
| HTTP | Remote servers, accessible over the network |
Workflow
Step 1: Choose your language and SDK
| Language | SDK | Install |
| Python | mcp | pip install mcp |
| TypeScript | @modelcontextprotocol/sdk | npm install @modelcontextprotocol/sdk |
Step 2: Define your tools
Each tool has a name, description, and JSON Schema for its parameters:
from mcp import Server, Tool
from mcp.types import ToolSchema
server = Server("my-server")
@server.tool()
async def search_database(query: str, limit: int = 10) -> str:
"""Search the database for matching records.
Args:
query: The search query string
limit: Maximum number of results to return
"""
# Your search logic here
results = await db.search(query, limit=limit)
return json.dumps(results)Step 3: Implement handlers
The handler is the function that runs when the agent calls the tool. It receives the arguments as a dict and returns a string (or structured content).
@server.tool()
async def get_file(path: str) -> str:
"""Read a file from the local filesystem."""
try:
with open(path, 'r') as f:
return f.read()
except FileNotFoundError:
return f"Error: File not found at {path}"
except PermissionError:
return f"Error: Permission denied for {path}"Step 4: Register resources (optional)
Resources are URIs the agent can read:
@server.resource("config://app")
async def get_config() -> str:
"""Return the application configuration."""
return json.dumps({"version": "1.0", "debug": False})Step 5: Choose transport and run
stdio (local):
import asyncio
from mcp.server.stdio import stdio_server
async def main():
async with stdio_server() as (read_stream, write_stream):
await server.run(read_stream, write_stream)
asyncio.run(main())HTTP (remote):
from mcp.server.sse import sse_server
async def main():
async with sse_server("0.0.0.0", 8080) as (read_stream, write_stream):
await server.run(read_stream, write_stream)
asyncio.run(main())Step 6: Test with an MCP client
# Using the MCP inspector (comes with the SDK)
mcp inspect python my_server.py
# Or connect from an agent that supports MCP
# Hermes: hermes mcp add my-server --command "python my_server.py"
# Claude Desktop: add to claude_desktop_config.jsonTool Schema
Every tool needs a clear JSON Schema so the agent knows what arguments to pass:
TOOL_SCHEMA = {
"name": "search_database",
"description": "Search the database for matching records.",
"inputSchema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query string"
},
"limit": {
"type": "integer",
"description": "Maximum results to return",
"default": 10
}
},
"required": ["query"]
}
}Good descriptions are critical — the agent uses them to decide when to call the tool.
Full Example: File Search Server
#!/usr/bin/env python3
import asyncio
import json
import os
from mcp import Server
from mcp.server.stdio import stdio_server
server = Server("file-search")
@server.tool()
async def search_files(directory: str, pattern: str) -> str:
"""Search for files matching a pattern in a directory.
Args:
directory: The root directory to search in
pattern: Filename pattern (e.g., '*.py', '*.json')
"""
import fnmatch
matches = []
for root, dirs, files in os.walk(directory):
for filename in fnmatch.filter(files, pattern):
matches.append(os.path.join(root, filename))
return json.dumps(matches[:50], indent=2)
@server.tool()
async def read_file(path: str) -> str:
"""Read the contents of a file."""
try:
with open(path, 'r') as f:
return f.read()[:10000] # cap at 10k chars
except Exception as e:
return f"Error: {e}"
@server.resource("stats://file-search")
async def get_stats() -> str:
"""Return search statistics."""
return json.dumps({"server": "file-search", "version": "1.0"})
async def main():
async with stdio_server() as (read_stream, write_stream):
await server.run(read_stream, write_stream)
if __name__ == "__main__":
asyncio.run(main())Connecting to Hermes
# Add as a stdio server
hermes mcp add file-search --command "python /path/to/file_search_server.py"
# Add as an HTTP server
hermes mcp add file-search --url http://localhost:8080
# Test the connection
hermes mcp test file-search
# List available tools from the server
hermes mcp listCommon Pitfalls
- Vague tool descriptions. The agent decides whether to call a tool based on its description alone. "Searches stuff" won't get called. "Searches the database for records matching a query string, returns up to N results as JSON" will.
- No error handling. Tools that crash on bad input break the agent's whole turn. Always catch exceptions and return error messages as strings — never let a handler raise unhandled.
- Returning too much data. Agents have context limits. Cap returns at a reasonable size (10k chars, 50 results as shown above) and let the agent ask for more if needed.
- No input validation. Validate paths, queries, and parameters before processing. Don't trust the agent to send valid input — it will occasionally pass malformed or out-of-range values.
- Blocking operations inside async handlers. MCP handlers should be async. Blocking I/O (file reads, database queries) run inline stalls the whole server; run them in a thread executor.
- Transport mismatch. stdio servers are launched by the agent process and read/write over the process pipes; HTTP servers must be running independently before the agent connects. Don't try to serve HTTP over stdio or vice versa.
- Forgetting the session is cached. After adding a new tool to a running server, some MCP clients (including Hermes) cache the tool list from initial connection — reconnect or restart the client to see new tools.
Verification Checklist
mcp inspect python my_server.py(or equivalent) lists every tool with its schema and description- Each tool returns a string/structured result for both valid and invalid input — no unhandled exception in the server logs
- stdio servers are invoked by the client's own command (not left running as an orphan process); HTTP servers are confirmed reachable with
curlbefore wiring into the client hermes mcp test <name>(or the equivalent client-side test) succeeds and the tool list matches what the server defines- A sample call to at least one tool returns the expected data end-to-end, not just a schema-level pass
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.

