A comprehensive Model Context Protocol (MCP) implementation for network diagnostics. This monorepo consists of an MCP server providing network diagnostic tools and an MCP client that integrates with AI language models to enable intelligent, conversational network analysis.
Networks Project MCP is a distributed system that combines:
- MCP Server: Provides network diagnostic tools (DNS lookup, ping, traceroute, GeoIP lookup)
- MCP Client: Connects to the server and integrates with AI models for intelligent tool execution
- Model Context Protocol: Enables seamless communication between AI models and external tools
The project demonstrates how to build a practical application using the Model Context Protocol, allowing AI models to execute real-world network diagnostic commands and provide meaningful analysis.
networks-project-mcp/
βββ package.json # Monorepo workspace configuration
βββ packages/
β βββ mcp-server/ # Network diagnostics MCP server
β β βββ src/
β β β βββ index.ts # Server entry point
β β β βββ server.ts # MCP server configuration
β β β βββ lib/ # Core libraries
β β β β βββ command.ts # Command execution utilities
β β β β βββ sse.ts # Server-Sent Events setup
β β β β βββ stream.ts # Stream utilities
β β β βββ tools/ # Network diagnostic tools
β β β β βββ dnsLookup.ts
β β β β βββ geoIPLookup.ts
β β β β βββ pingStream.ts
β β β β βββ tracerouteStream.ts
β β β βββ prompts/ # AI prompt templates
β β β β βββ detailedTraceroute.ts
β β β β βββ verifyTraceroute.ts
β β β βββ resources/ # Documentation resources
β β β β βββ digManPage.ts
β β β β βββ pingManPage.ts
β β β β βββ tracerouteManPage.ts
β β β βββ man/ # Man page files
β β βββ docker-compose.yml # Docker composition for server
β β βββ Dockerfile # Docker configuration
β β βββ tsconfig.json
β β βββ package.json
β β
β βββ mcp-client/ # Interactive MCP client
β βββ src/
β β βββ index.ts # Client entry point
β β βββ core/ # Core client modules
β β β βββ config.ts # Configuration management
β β β βββ llmClient.ts # LLM integration
β β β βββ mcpServer.ts # MCP server connection
β β β βββ toolInfo.ts # Tool metadata
β β βββ session/ # Session management
β β β βββ chatSession.ts # Chat session orchestration
β β β βββ sseManager.ts # SSE stream management
β β βββ ui/ # User interface
β β βββ terminal.ts # Terminal UI
β βββ servers_config.json # MCP server configuration
β βββ tsconfig.json
β βββ package.json
β
βββ README.md # This file
- Bun runtime (v1.2+)
- Node.js 16+ (for MCP SDK compatibility)
- Google Generative AI API key (for the client)
- macOS (currently the man pages are for macOS; Linux/Windows support coming soon)
-
Clone and navigate to the project:
cd /Users/rayvego/code/courage/networks-project-mcp -
Install dependencies and build:
bun install bun run build
-
Configure the client (in
packages/mcp-client):cp .env.example .env
Then add your Google Generative AI API key:
GOOGLE_API_KEY=your_api_key_here
Option 1: Quick Start (All-in-One)
bun run startThis command:
- Installs all dependencies
- Builds both server and client
- Starts the MCP client in interactive mode
Option 2: Development Mode
# Terminal 1: Start the MCP server
cd packages/mcp-server
bun run dev
# Terminal 2: Start the MCP client
cd packages/mcp-client
bun run devOption 3: Docker
# Build and run the MCP server with Docker
cd packages/mcp-server
docker-compose upA Model Context Protocol server that exposes network diagnostic tools to AI models and MCP clients.
-
DNS Lookup (
dnsLookup)- Performs DNS queries using the
digcommand - Returns DNS records for a given domain
- Supports custom query types (A, AAAA, MX, NS, TXT, etc.)
- Performs DNS queries using the
-
GeoIP Lookup (
geoIPLookup)- Retrieves geographic location information for IP addresses
- Returns country, city, coordinates, and ISP details
- Uses the geoiplookup.io API
-
Ping Stream (
pingStream)- Real-time ping execution with streaming output
- Tracks latency, packet loss, and response times
- Uses Server-Sent Events (SSE) for live updates
-
Traceroute Stream (
tracerouteStream)- Real-time traceroute execution with streaming output
- Shows network path to destination hosts
- Includes hop-by-hop analysis
- Verify Traceroute - Guides analysis of traceroute results
- Detailed Traceroute - Provides comprehensive traceroute analysis
- Man pages for
dig,ping, andtraceroutecommands - Accessible via the MCP resource protocol
- Command Execution (
lib/command.ts): Executes system commands with proper error handling - Streaming (
lib/stream.ts): Manages real-time command output streaming - SSE Server (
lib/sse.ts): Provides Server-Sent Events for streaming results
An interactive terminal client that connects to MCP servers and uses an AI model to intelligently execute tools.
- π€ LLM Integration: Uses Google's Gemini AI model for natural language understanding
- π§ Multiple Server Support: Can connect to multiple MCP servers simultaneously
- π Automatic Tool Execution: LLM determines which tools to use based on user queries
- π Progress Tracking: Visual feedback for long-running operations
- π Retry Mechanism: Built-in retry logic for robust execution
- π¬ Conversational Interface: Natural chat-based interaction
- Configuration (
core/config.ts): Manages environment variables and settings - LLM Client (
core/llmClient.ts): Handles communication with the AI model - MCP Server Connection (
core/mcpServer.ts): Manages connections to MCP servers - Tool Info (
core/toolInfo.ts): Caches and formats tool metadata - Chat Session (
session/chatSession.ts): Orchestrates user input, LLM calls, and tool execution - SSE Manager (
session/sseManager.ts): Manages streaming responses from tools - Terminal UI (
ui/terminal.ts): Provides user-friendly terminal interface
$ bun run start
π Connected to network-diagnostics MCP server
π‘ Available tools: dnsLookup, geoIPLookup, pingStream, tracerouteStream
You: What's the IP address of github.com and where is it located?
π€ Executing tools...
ββ dnsLookup for github.com
ββ geoIPLookup for 20.200.245.247
β¨ Response:
GitHub.com resolves to 20.200.245.247. This IP address is located in
Ashburn, Virginia, United States, and is hosted by Microsoft Corporation.
You: {
"mcpServers": {
"network-diagnostics": {
"command": "bun",
"args": [
"/Users/rayvego/code/courage/networks-project-mcp/packages/mcp-server/dist/index.js"
]
}
}
}Modify this file to add additional MCP servers or change how the server is launched.
Create a .env file in packages/mcp-client with:
GOOGLE_API_KEY=your_api_key_here
# Build entire project
bun run build
# Build only the server
cd packages/mcp-server && bun run build
# Build only the client
cd packages/mcp-client && bun run build# Server (with auto-reload)
cd packages/mcp-server && bun run dev
# Client (with auto-reload)
cd packages/mcp-client && bun run dev| Command | Description |
|---|---|
bun run build |
Build both server and client |
bun run start |
Install, build, and start the client |
The MCP server provides:
- Stdio Transport - Standard input/output for MCP communication
- HTTP/SSE Server - Runs on a configurable port for streaming tool outputs
Each tool follows the MCP Tool Definition schema with:
name: Unique identifierdescription: Human-readable descriptioninputSchema: Zod-validated input parametershandler: Async function that executes the tool
Example tool structure:
{
name: "dnsLookup",
definition: {
description: "Perform DNS queries...",
inputSchema: {
type: "object",
properties: { /* ... */ }
}
},
handler: async (params, elicitationRequest) => { /* ... */ }
}The MCP server can be containerized for deployment:
cd packages/mcp-server
docker build -t network-diagnostics-mcp .
docker run -p 3000:3000 network-diagnostics-mcpOr use docker-compose:
docker-compose upCurrently, the project focuses on functionality testing through manual runs. To test:
- Start the server
- Run the client
- Issue network diagnostic queries
Example queries to test:
- "What's the IP address of google.com?"
- "Trace the route to amazon.com"
- "Ping example.com 5 times"
- "Where is the IP address 8.8.8.8 located?"
Contributions are welcome! Areas for improvement:
- Add unit and integration tests
- Support for Linux and Windows man pages
- Additional network diagnostic tools (nslookup, whois, etc.)
- Web-based UI
- Caching for repeated queries
- Performance optimizations for streaming
- Additional LLM provider support
- Check that port 3000 is not in use
- Verify Bun is installed:
bun --version - Check that the MCP SDK is properly installed
- Ensure the server is running
- Check
servers_config.jsonhas correct server path - Verify API key is set in
.env
- Verify
GOOGLE_API_KEYis set correctly - Check internet connectivity
- Verify API quota hasn't been exceeded
- Ensure the SSE server port is not blocked
- Check firewall settings
- Verify network connectivity
- Model Context Protocol Documentation
- Bun Documentation
- Google Generative AI API
- MCP SDK for TypeScript
MIT
This project is part of CS331 Networks course work, demonstrating practical application of network diagnostic tools through an AI-integrated interface.
Last Updated: November 2025 Version: 1.0.0