From matematic-mcp-fastmcp-instructions-pl
Buduj nowy MCP server MateMatic (lub retrofit istniejacego) z 5 elementami zwalidowanymi na dograh v1.31.0 - FastMCP(instructions=) z procedural orchestration, drift test, dwukanalowy auth X-API-Key LUB Bearer, OTel atrybut org_id dla per-tenant routing, ToolAnnotations dla read-only. Uzywaj gdy zaczynasz nowy MCP server (saos/eu-compliance/anonimizacja/pomoc-prawna/kio/isap/inny), retrofit istniejacego do tego patternu, dodajesz nowy tool do MCP, debugujesz dlaczego LLM nie wywoluje Twoich tooli w odpowiedniej kolejnosci, lub gdy klient MCP (Claude Code/Cursor) nie autoryzuje. Trigger - "nowy MCP", "buduj MCP server", "FastMCP", "instructions MCP", "dryft testu MCP", "Claude Code MCP", "auth MCP", "OTel MCP", "FastMCP setup", "retrofit MCP", "tools MCP audit", "tools MCP nie sa wywolywane".
How this skill is triggered — by the user, by Claude, or both
Slash command
/matematic-mcp-fastmcp-instructions-pl:matematic-mcp-fastmcp-instructions-plThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Wzorzec kanoniczny dla MCP serverow MateMatic. Walidowany empirycznie na [dograh-hq/dograh](https://github.com/dograh-hq/dograh) v1.31.0 (production system, 3-4 dni release cycle, 2.6k gwiazdek, drift testy w CI, BSD-2).
Wzorzec kanoniczny dla MCP serverow MateMatic. Walidowany empirycznie na dograh-hq/dograh v1.31.0 (production system, 3-4 dni release cycle, 2.6k gwiazdek, drift testy w CI, BSD-2).
FastMCP(instructions=...) z procedural orchestrationInstrukcje wstrzykiwane do system promptu kazdego klienta MCP. LLM widzi je PRZED pierwszym tool call.
Tresc:
Anti-content:
tools/list)PropertySpec.llm_hint)Wzor (Python):
from fastmcp import FastMCP
from .instructions import MY_MCP_INSTRUCTIONS
from .tools.foo import foo_tool
from .tools.bar import bar_tool
mcp = FastMCP("matematic-saos", instructions=MY_MCP_INSTRUCTIONS)
for _tool in (foo_tool, bar_tool):
mcp.tool(_tool)
tests/test_mcp_instructions_drift.py)Fail jesli:
Wzor w examples/test_instructions_drift.py.
FastMCP domyslnie stripuje Authorization header. MUSISZ explicit get_http_headers(include={"authorization"}).
from fastmcp.server.dependencies import get_http_headers
async def authenticate_mcp_request() -> User:
headers = get_http_headers(include={"authorization"})
api_key = headers.get("x-api-key")
if not api_key:
auth = headers.get("authorization", "")
if auth.lower().startswith("bearer "):
api_key = auth.split(" ", 1)[1].strip()
if not api_key:
raise HTTPException(
status_code=401,
detail="Missing API key - send X-API-Key or Authorization: Bearer <key>",
)
return await _handle_api_key_auth(api_key)
<server>.org_id per-tenant routingPer-org routing do Langfuse/observability:
from opentelemetry import trace
span = trace.get_current_span()
if span.is_recording():
org_id = user.selected_organization_id
span.set_attribute("mcp.org_id", str(org_id))
span.set_attribute("mcp.user_id", str(user.id))
span.set_attribute("langfuse.user.id", str(user.id))
WAZNE rozroznienie z dograh-auth:
<server>.org_id (np. dograh.org_id) triggeruje per-org Langfuse project routing dla pipeline spansmcp.org_id zeby zostalo na default (developer-facing) projectPozwala klientowi MCP automatycznie zatwierdzac wywolania bez monitu (readOnlyHint=True + destructiveHint=False).
from mcp.types import ToolAnnotations
_READ_ONLY = ToolAnnotations(
readOnlyHint=True,
idempotentHint=True,
destructiveHint=False,
openWorldHint=False,
)
for _tool in (list_docs, search_docs, read_doc):
mcp.tool(_tool, annotations=_READ_ONLY)
W examples/:
server.py - kanon setup FastMCP + registrationinstructions.py - szkielet z 4 sekcjami (Call order / Allowed shape / Iterating on errors / Style)auth.py - dwukanalowy + OTeltest_instructions_drift.py - drift test do CIclaude mcp add --transport http <name> https://<your-mcp>/api/v1/mcp/ \
--header "X-API-Key: <key>"
claude mcp list
# Powinno wyswietlic <name> + status connected + tools count
W Claude Code: "List my via " - czy LLM wywoluje tool wlasciwy?
| Anti-pattern | Konsekwencja |
|---|---|
| Restating tool signatures w instructions | Drift, signatury rosna z kodu |
| Re-enumerating error_codes w instructions | Drift, error_codes rosna z docstring |
| Hardcoded API key validation w kazdym tool | Reuse authenticate_mcp_request() |
Stdlib logging.info(request_body) | Loguruj sekrety. Uzyj Loguru z masking PII |
| Brak ToolAnnotations na read-only | Klient pyta o approval przy kazdym wywolaniu |
| Single-channel auth (tylko X-API-Key lub tylko Bearer) | Niektorzy klienci wysylaja drugi - 401 |
| Brak OTel atrybutow org_id | Brak per-tenant observability w multi-tenant |
api/mcp_server/server.py, api/mcp_server/instructions.py, api/mcp_server/auth.py w upstream repoLIVE 2026-05-25 (6 z 6 TypeScript MCP serverow MateMatic):
| MCP | Wersja | Release |
|---|---|---|
| mcp-eu-compliance | v0.2.0 | pilot kanonu |
| mcp-saos | v1.1.0 | orzecznictwo SAOS |
| mcp-eu-sparql | v1.1.0 | EUR-Lex + CJEU |
| mcp-isap | v1.1.0 | Sejm ELI (DU + MP) |
| mcp-nsa | v1.1.0 | CBOSA (sady admin) |
| mcp-krs | v1.1.0 | KRS MS |
Pozostalo (Python stack + nowsze MCP): sejm-eli-mcp, kio-orzeczenia-mcp, ewentualne uodo-mcp / pomoc-prawna-mcp.
npx claudepluginhub matematicsolutions/awesome-matematic-skills-pl --plugin matematic-mcp-fastmcp-instructions-plGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.