Your First MCP Server
Build and connect a custom MCP tool server
An MCP (Model Context Protocol) server exposes your infrastructure capabilities as callable tools. The Director discovers these tools and invokes them through on-prem agents when processing user requests. MCP servers run alongside your agents inside your network.
What is an MCP server?
An MCP server is a lightweight Python service that defines tools -- functions the AI can call to interact with your infrastructure. Tools can do anything: query a monitoring API, configure a network device, look up a DNS record, restart a service.
GNETiX uses FastMCP with Streamable HTTP transport for all MCP communication.
Build a server
Step
Create the project
mkdir my-mcp-server && cd my-mcp-serverCreate a requirements.txt:
fastmcpStep
Define your tools
Create a server.py file with your tool definitions:
from fastmcp import FastMCP
mcp = FastMCP("My Infrastructure Tools")
@mcp.tool()
def get_system_status(hostname: str) -> dict:
"""Check the operational status of a host.
Returns uptime, CPU load, and memory usage for the
specified hostname. Use this when a user asks about
the health of a specific system.
"""
# Replace with your actual infrastructure logic
return {
"hostname": hostname,
"status": "healthy",
"uptime_hours": 482,
"cpu_percent": 23.5,
"memory_percent": 61.2,
}
@mcp.tool()
def list_interfaces(device: str) -> list[dict]:
"""List all network interfaces on a device.
Returns interface name, status, and IP address for each
interface on the specified network device.
"""
# Replace with actual device query (e.g., Netmiko, NAPALM)
return [
{"name": "GigabitEthernet0/0", "status": "up", "ip": "10.0.1.1/24"},
{"name": "GigabitEthernet0/1", "status": "down", "ip": None},
]Tool docstrings are surfaced directly to the LLM. Write them clearly and include guidance on when the tool should be used. The function signature defines the parameters the Director will pass.
Step
Add the entrypoint
Add a main block to run the server with Streamable HTTP transport:
if __name__ == "__main__":
mcp.run(transport="streamable-http", host="0.0.0.0", port=8000)Step
Containerize it
Create a Dockerfile:
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY server.py .
EXPOSE 8000
CMD ["python", "server.py"]Build and run:
docker build -t my-mcp-server .
docker run -d --name my-mcp-server -p 8000:8000 my-mcp-serverRegister in the portal
Step
Add the MCP server
In the GNETiX portal, navigate to MCP Servers and click Add Server. Provide:
- Name: A human-readable label (e.g., "Network Tools")
- URL: The Streamable HTTP endpoint reachable from the agent (e.g.,
http://my-mcp-server:8000/mcp)
If your MCP server requires authentication, configure the OAuth client credentials in the server settings.
Step
Assign to an agent
Go to the agent you want to equip with these tools and assign the MCP server to it. An agent can have multiple MCP servers, and the same MCP server can be assigned to multiple agents.
Step
Sync tools
After assignment, click Sync Tools on the agent detail page. GNETiX connects to the MCP server, discovers all available tools, and registers them in the tool catalog.
The synced tools appear in the Inspector tab with their names, descriptions, and parameter schemas.
Test the tools
Send a message through any connected platform (Webex, Slack, Teams) that would naturally invoke your tool. For example:
What is the status of host web-prod-01?
The Director will identify the relevant tool, dispatch an A2A task to the agent, execute get_system_status("web-prod-01"), and return the result in the conversation.
Example MCP servers
The GNETiX examples repository contains ready-to-use MCP servers you can clone and customize:
git clone https://github.com/GNETiX-AI/mcp-server-examples.git
cd mcp-server-examples/network-mcp
docker build -t my-network-mcp .
docker run -d --name network-mcp -p 8000:8000 my-network-mcpAvailable examples include network devices (Netmiko), Kubernetes, Dynatrace, Cribl, and more.
Tool names use snake_case by convention. Keep them descriptive and specific -- get_bgp_neighbors is better than get_data.
Next steps
- Read the MCP Servers reference for advanced configuration (OAuth, tool filtering, multi-server patterns)
- Explore the Architecture page to understand how the Director routes tasks to agents
- Check the Pipeline Monitor to trace tool invocations in real time