Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Add McpTool for easy MCP Tool integration #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
feat: Add McpTool for easy MCP Tool integration #85
Changes from 1 commit
263a75dfc7a1b773af8a0b6113221c41b53File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Implements easy-to-integrate MCP server support using the official C# SDK, allowing Gemini models to use tools from any MCP server. Key Features: - McpTool class implementing IFunctionTool interface - Auto-discovery of tools from MCP servers - Support for multiple concurrent MCP servers - Automatic reconnection and error handling - Comprehensive configuration options Implementation: - McpServerConfig: Configure server connections (command, args, env vars) - McpToolOptions: Control behavior (auto-reconnect, error handling) - McpTool: Main class that bridges MCP servers with Google Generative AI - Async/await pattern with proper IDisposable/IAsyncDisposable support - Converts MCP tools to Google's FunctionDeclaration format - Forwards function calls to MCP servers and converts responses Example Usage: var config = new McpServerConfig { Name = "my-server", Command = "npx", Arguments = new List<string> { "-y", "@modelcontextprotocol/server-everything" } }; using var mcpTool = await McpTool.CreateAsync(config); var model = new GenerativeModel(apiKey, "gemini-2.0-flash-exp"); model.AddFunctionTool(mcpTool); Files Added: - src/GenerativeAI.Tools/Mcp/McpServerConfig.cs - src/GenerativeAI.Tools/Mcp/McpTool.cs - src/GenerativeAI.Tools/Mcp/README.md - samples/McpIntegrationDemo/ (complete example project) - MCP_INTEGRATION_SUMMARY.md Dependencies: - Added ModelContextProtocol v0.4.0-preview.3 NuGet packageUh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Uh oh!
There was an error while loading. Please reload this page.