- Explore MCP Servers
- gemma-mcp
Gemma Mcp
What is Gemma Mcp
Gemma MCP Client is a Python package that integrates Google’s Gemma language model with the Model Content Protocol (MCP) server, allowing for advanced function calling capabilities. It supports local Python functions and remote MCP tools, ensuring seamless communication and automation.
Use cases
The Gemma MCP Client can be used in various scenarios such as chatbots, weather applications, virtual assistants, and any other applications requiring natural language processing alongside function execution. It enables both local and remote interactions, making it versatile for multiple domains.
How to use
To use the Gemma MCP Client, install the package, configure the MCP servers, and initialize the client. Users can add local functions directly through callables, dictionaries, or FunctionDefinition objects. The client supports executing messages with function capabilities, managing resources with async context managers.
Key features
Key features of the Gemma MCP Client include seamless integration with the Gemma model, support for automatic tool discovery and registration from MCP servers, Pythonic function calling syntax, resource management with async context managers, and multi-server support, along with easy testing capabilities.
Where to use
Gemma MCP Client is ideal for use cases in natural language processing environments where function execution is required, such as AI chatbots, data retrieval systems, automated assistants, and other applications that benefit from both structured and unstructured data interactions.
Overview
What is Gemma Mcp
Gemma MCP Client is a Python package that integrates Google’s Gemma language model with the Model Content Protocol (MCP) server, allowing for advanced function calling capabilities. It supports local Python functions and remote MCP tools, ensuring seamless communication and automation.
Use cases
The Gemma MCP Client can be used in various scenarios such as chatbots, weather applications, virtual assistants, and any other applications requiring natural language processing alongside function execution. It enables both local and remote interactions, making it versatile for multiple domains.
How to use
To use the Gemma MCP Client, install the package, configure the MCP servers, and initialize the client. Users can add local functions directly through callables, dictionaries, or FunctionDefinition objects. The client supports executing messages with function capabilities, managing resources with async context managers.
Key features
Key features of the Gemma MCP Client include seamless integration with the Gemma model, support for automatic tool discovery and registration from MCP servers, Pythonic function calling syntax, resource management with async context managers, and multi-server support, along with easy testing capabilities.
Where to use
Gemma MCP Client is ideal for use cases in natural language processing environments where function execution is required, such as AI chatbots, data retrieval systems, automated assistants, and other applications that benefit from both structured and unstructured data interactions.
Content
Gemma MCP Client
A Python package that combines Google’s Gemma language model with MCP (Model Content Protocol) server integration, enabling powerful function calling capabilities across both local functions and remote MCP tools.
Features
- Seamless integration with Google’s Gemma language model
- Support for both local Python functions and remote MCP tools
- Automatic tool discovery and registration from MCP servers
- Python-style function calling syntax
- Proper resource management with async context managers
- Support for multiple MCP servers
- Easy testing through test server support
Installation
uv add gemma-mcp # or pip install gemma-mcp if you love the old way
Requirements
- Python 3.10+
google-genai
: Google Generative AI Python SDKFastMCP
MCP utilities
Usage
Basic Usage
from gemma_mcp import GemmaMCPClient
# a standard MCP configuration
mcp_config = {
"mcpServers": {
"weather": {
"url": "https://weather-api.example.com/mcp"
},
"assistant": {
"command": "python",
"args": ["./assistant_server.py"]
}
}
}
# Initialize client with MCP support
async with GemmaMCPClient(mcp_config=mcp_config).managed() as client:
# Chat with automatic function execution
response = await client.chat(
"What's the weather like in London?",
execute_functions=True
)
print(response)
Adding Local Functions
You can add local functions in three ways:
- Using a callable:
async def my_function(param1: str, param2: int = 0):
"""Function description."""
return {"result": param1 + str(param2)}
client.add_function(my_function)
- Using a dictionary:
function_def = {
"name": "my_function",
"description": "Function description",
"parameters": {
"type": "object",
"properties": {
"param1": {"type": "string"},
"param2": {"type": "integer", "default": 0}
},
"required": ["param1"]
}
}
client.add_function(function_def)
- Using a FunctionDefinition object:
from gemma_mcp import FunctionDefinition
function_def = FunctionDefinition(
name="my_function",
description="Function description",
parameters={
"type": "object",
"properties": {
"param1": {"type": "string"},
"param2": {"type": "integer", "default": 0}
},
"required": ["param1"]
},
required=["param1"]
)
client.add_function(function_def)
MCP Server Configuration
The MCP configuration supports multiple server types:
- servers with SSE transport:
mcp_config = {
"mcpServers": {
"server_name": {
"url": "https://server-url/mcp"
}
}
}
- servers with STDIO transport:
mcp_config = {
"mcpServers": {
"server_name": {
"command": "python",
"args": ["./server.py"]
}
}
}
Testing
The package includes support for testing with in-memory MCP servers:
from fastmcp import FastMCP
from gemma_mcp import GemmaMCPClient
# Create test server
mcp = FastMCP("Test Server")
# Initialize client with test server
client = GemmaMCPClient()
client.mcp_client.add_test_server(mcp)
# Use the client as normal
async with client.managed():
response = await client.chat("Test message", execute_functions=True)
API Reference
GemmaMCPClient
The main client class that handles both Gemma model interactions and MCP tool integration.
Parameters
api_key
(str, optional): Gemini API key. If not provided, will look for GEMINI_API_KEY env varmodel
(str): Model to use, defaults to “gemma-3-27b-it”temperature
(float): Generation temperature, defaults to 0.7system_prompt
(str, optional): Custom system promptmcp_config
(dict, optional): MCP configuration dictionary
Methods
add_function(function)
: Add a function definitionchat(message, execute_functions=False)
: Send a message and get responseinitialize()
: Initialize the client and all componentscleanup()
: Clean up all resources
FunctionDefinition
A dataclass for representing function definitions.
Parameters
name
(str): Function namedescription
(str): Function descriptionparameters
(dict): Function parameters schemarequired
(list): List of required parameterscallable
(callable, optional): The actual callable function
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.