Learn how to define GolfMCP components (tools, resources, prompts).
export
)export
.
export
variable is not found, GolfMCP build will fail.
param: str
, count: int
).-> str
, -> Dict[str, Any]
).async def
or def
.resource_uri: str
.resource_uri = "data://config"
str
(which becomes a single user message) or a List[Dict]
.BaseModel
is highly recommended for defining complex input argument structures and output shapes, enabling clear schemas and validation for FastMCP.
BaseModel
for this return type to ensure a clear and validated output schema.
Annotated
with Pydantic Field
provides rich descriptions and validation that significantly improves how AI agents understand and use your tools.
annotations
dictionary at the module level to specify behavioral hints:
true
→ tool cannot change state (pure “GET-style” call)Note: When true
, other hints are ignored by MCP clients.true
→ tool may delete or irreversibly mutate dataOnly meaningful when readOnlyHint
is false
.true
→ repeated calls with identical arguments are safe and side-effect-freeHelps MCP clients add caching and deduplication.true
→ behavior depends on external mutable state (e.g., live web, clock)Signals lower reproducibility to MCP clients.