Documentation
¶
Overview ¶
Example: mcp_agent demonstrates connecting an agent to a Model Context Protocol (MCP) server and importing its tools into the agent's registry.
It launches the official filesystem MCP server over stdio, registers every tool the server exposes, and prints them. If an OpenAI API key is present, the agent then answers a prompt that can use those tools.
Prerequisites (for a live run):
npm install -g @modelcontextprotocol/server-filesystem # or use npx
Run:
go run ./examples/mcp_agent/
The example degrades gracefully: if the MCP server binary is not installed, it prints the connection error and exits 0 so it stays CI-safe.
Click to show internal directories.
Click to hide internal directories.