Skip to main content
Glama

Genkit MCP

Official
by firebase
README.md2.44 kB
# Simple MCP Demo This demo shows how you can use Genkit's MCP package to expose an MCP Server that can be used by external consumers like Claude Desktop, VS Code with MCP, and other useful tools and clients. ## Files - `server.go` - MCP server with 2 tools: `text_encode` and `hash_generate` - `run-server.sh` - Simple wrapper script for easy client setup - `client.go` - Client that uses tools with Gemini AI ## Two Ways to Run ### Option A: Expose an MCP Server that works with Desktop Clients #### Step 1: Test the server works ```bash ./run-server.sh ``` You should see: `Starting server with tools: [text_encode hash_generate]` #### Step 2: Configure client. Point your client to run that bash command to start the server. Make sure you restart the client to ensure the server is properly started. #### Step 4: Test your assistant's connection to the MCP server with these quries: - *"Encode 'Hello World' as base64"* - *"Generate an MD5 hash of 'password123'"* - *"Decode this base64: SGVsbG8gV29ybGQ="* ### Option B: Genkit MCP Client spawns the MCP Server First, change `client()` to `main()` in `go/samples/mcp-server/client.go`. Then follow the steps below: ```bash export GOOGLE_AI_API_KEY=your_key go run client.go ``` The `GenkitMCPClient` instance automatically spawns the server and makes tools available to use with `client.GetActiveTools()`. You can use these tools with any `Generate` method or `ExecutablePrompt`. Alternatively, you can use the `MCPManager` for managing multiple servers: ```go manager, _ := mcp.NewMCPManager(mcp.MCPManagerOptions{ Name: "my-app", MCPServers: []mcp.MCPServerConfig{ { Name: "textUtils", Config: mcp.MCPClientOptions{ Stdio: &mcp.StdioConfig{ Command: "go", Args: []string{"run", "server.go"}, }, }, }, { Name: "otherServer", Config: mcp.MCPClientOptions{ URL: "http://localhost:8080/mcp", }, }, }, }) ``` This example demonstrates the following workflow: 1. Client connects to server via MCP protocol 2. AI gets prompt: "Fetch content from URL and summarize it" 3. AI automatically calls `fetch_url` then `summarize` 4. Returns the summary This option is useful when you have an genkit agent that needs access to utilities developed in the same project.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/firebase/genkit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server