fastmcp

Build, test, and deploy Python MCP servers.

  • MCP
  • FastMCP
  • Python
  • Tools
  • Resources
  • Prompts
  • Deployment

Declared platforms: linux · macos · windows

Install
npx skills add 'https://github.com/NousResearch/hermes-agent/tree/main/optional-skills/mcp/fastmcp'
Download bundle ↓
main · 24fd22bScanned 2026-09-15

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md
from __future__ import annotations import osfrom typing import Any import httpxfrom fastmcp import FastMCP  mcp = FastMCP("__SERVER_NAME__") API_BASE_URL = os.getenv("API_BASE_URL", "https://api.example.com")API_TOKEN = os.getenv("API_TOKEN")REQUEST_TIMEOUT = float(os.getenv("API_TIMEOUT_SECONDS", "20"))  def _headers() -> dict[str, str]:    headers = {"Accept": "application/json"}    if API_TOKEN:        headers["Authorization"] = f"Bearer {API_TOKEN}"    return headers  def _request(method: str, path: str, *, params: dict[str, Any] | None = None) -> Any:    url = f"{API_BASE_URL.rstrip('/')}/{path.lstrip('/')}"    with httpx.Client(timeout=REQUEST_TIMEOUT, headers=_headers()) as client:        response = client.request(method, url, params=params)        response.raise_for_status()        return response.json()  @mcp.tooldef health_check() -> dict[str, Any]:    """Check whether the upstream API is reachable."""    payload = _request("GET", "/health")    return {"base_url": API_BASE_URL, "result": payload}  @mcp.tooldef get_resource(resource_id: str) -> dict[str, Any]:    """Fetch one resource by ID from the upstream API."""    payload = _request("GET", f"/resources/{resource_id}")    return {"resource_id": resource_id, "data": payload}  @mcp.tooldef search_resources(query: str, limit: int = 10) -> dict[str, Any]:    """Search upstream resources by query string."""    payload = _request("GET", "/resources", params={"q": query, "limit": limit})    return {"query": query, "limit": limit, "results": payload}  if __name__ == "__main__":    mcp.run() 
Referenced from SKILL.md