Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Claude Code Project Memory

## Git Conventions

### Commit Authorship
- **Author Name**: Gunpal Jain
- **Author Email**: gunpal5@gmail.com
- **Do NOT use "Claude" or "noreply@anthropic.com"** - all commits should be authored by Gunpal Jain

### Branch Naming
- Use descriptive branch names without "claude" prefix
- Preferred formats:
- `feature/description` - for new features
- `fix/description` - for bug fixes
- `refactor/description` - for refactoring
- `docs/description` - for documentation
- `mcp-integration` or similar descriptive names

**Important**: Do NOT use "claude/" prefix in branch names unless technically required by the environment.

### Commit Messages
- Use conventional commit format: `type: description`
- Types: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`
- Keep messages clear and professional
- No need to mention "Claude" or AI assistance in commit messages

## Repository Information

### Project
Google_GenerativeAI - Unofficial C# .NET SDK for Google Generative AI (Gemini) and Vertex AI

### Owner
- Name: Gunpal Jain
- GitHub: gunpal5
- Email: gunpal5@gmail.com

### Key Directories
- `/src/GenerativeAI/` - Core SDK
- `/src/GenerativeAI.Tools/` - Tool implementations
- `/src/GenerativeAI.Microsoft/` - Microsoft.Extensions.AI integration
- `/samples/` - Example projects
- `/tests/` - Test projects

### Current Work
MCP (Model Context Protocol) integration with support for all transport protocols (stdio, HTTP/SSE).

### Code Style
- C# with latest language features
- Nullable reference types enabled
- Comprehensive XML documentation
- Follow existing patterns in the codebase

## Notes
- When creating PRs, ensure clear descriptions and link related issues
- Run tests before committing (when possible)
- Follow semantic versioning for releases
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- [Gemini Tools and Function Calling](#gemini-tools-and-function-calling)
- [1. Inbuilt Tools (GoogleSearch, GoogleSearchRetrieval, and Code Execution)](#gemini-tools-and-function-calling)
- [2. Function Calling](#gemini-tools-and-function-calling)
- [3. MCP Server Integration](#4-mcp-model-context-protocol-server-integration)
- [Image Generation and Captioning](#image-generation-and-captioning)
- [Multimodal Live API](#multimodal-live-api)
- [Retrieval-Augmented Generation](#retrieval-augmented-generation)
Expand Down Expand Up @@ -504,6 +505,68 @@ model.AddFunctionTool(service.AsGoogleFunctionTool());
---

**For more details and options, see the [wiki](https://github.com/gunpal5/Google_GenerativeAI/wiki/Function-Calling).**

---

- ### 4. MCP (Model Context Protocol) Server Integration

Integrate MCP servers to expose tools from any MCP-compatible server to Gemini. Supports **all transport protocols**: stdio, HTTP/SSE, and custom transports.

**Stdio Transport** (Launch MCP server as subprocess):
```csharp
// Create stdio transport
var transport = McpTransportFactory.CreateStdioTransport(
"my-server",
"npx",
new[] { "-y", "@modelcontextprotocol/server-everything" }
);

using var mcpTool = await McpTool.CreateAsync(transport);

var model = new GenerativeModel("YOUR_API_KEY", GoogleAIModels.Gemini2Flash);
model.AddFunctionTool(mcpTool);
model.FunctionCallingBehaviour.AutoCallFunction = true;
```

**HTTP/SSE Transport** (Connect to remote MCP server):
```csharp
// Create HTTP transport
var transport = McpTransportFactory.CreateHttpTransport("http://localhost:8080");

// Or with authentication
var authTransport = McpTransportFactory.CreateHttpTransportWithAuth(
"https://api.example.com",
"your-auth-token"
);

using var mcpTool = await McpTool.CreateAsync(transport);
model.AddFunctionTool(mcpTool);
```

**Multiple MCP Servers**:
```csharp
var transports = new List<IClientTransport>
{
McpTransportFactory.CreateStdioTransport("server1", "npx", new[] { "..." }),
McpTransportFactory.CreateHttpTransport("http://localhost:8080")
};

var mcpTools = await McpTool.CreateMultipleAsync(transports);
foreach (var tool in mcpTools)
{
model.AddFunctionTool(tool);
}
```

**Key Features**:
- Supports stdio, HTTP/SSE, and custom transports
- Auto-discovery of tools from MCP servers
- Multiple concurrent servers
- Auto-reconnection support
- Works with any MCP-compatible server (Node.js, Python, C#, etc.)

**See [samples/McpIntegrationDemo](samples/McpIntegrationDemo) for complete examples.**

---
## Image Generation and Captioning

Expand Down
16 changes: 16 additions & 0 deletions samples/McpIntegrationDemo/McpIntegrationDemo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\GenerativeAI\GenerativeAI.csproj" />
<ProjectReference Include="..\..\src\GenerativeAI.Tools\GenerativeAI.Tools.csproj" />
</ItemGroup>

</Project>
Loading
Loading