Skip to main content
Glama
MCP Server Demo - Learning Project

MCP Server Demo - Learning Project

MCP Server Demo - Learning Project

A comprehensive learning project demonstrating how to build a Model Context Protocol (MCP) server with Google ADK integration using best practices.

🎯 Learning Objectives

This project teaches you:

  1. MCP Server Architecture

    • How to structure an MCP server

    • Tool definitions and handlers

    • Resource management

    • Error handling patterns

  2. Best Practices

    • TypeScript for type safety

    • Separation of concerns

    • Input validation and security

    • Error handling

    • Extensible architecture

  3. Google ADK Integration

    • Integration points for Google Actions

    • Analytics and logging

    • Fulfillment handlers (placeholder)

Related MCP server: Minimal MCP

πŸ“ Project Structure

mcp-server-demo/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # Main server entry point
β”‚   β”œβ”€β”€ tools/
β”‚   β”‚   β”œβ”€β”€ base-tool.ts      # Base tool interface
β”‚   β”‚   β”œβ”€β”€ calculator.ts     # Calculator tool example
β”‚   β”‚   β”œβ”€β”€ file-operations.ts # File operations tool
β”‚   β”‚   └── system-info.ts    # System information tool
β”‚   └── integrations/
β”‚       └── google-adk.ts     # Google ADK integration
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js 18+

  • npm or yarn

Installation

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode (with auto-reload)
npm run dev

# Run the built server
npm start

πŸ› οΈ Available Tools

1. Calculator Tool

Perform basic mathematical operations.

Example:

{
  "name": "calculator",
  "arguments": {
    "operation": "add",
    "a": 10,
    "b": 5
  }
}

2. File Operations Tool

Read, write, list, and get info about files.

Example:

{
  "name": "file_operations",
  "arguments": {
    "operation": "read",
    "path": "README.md"
  }
}

3. System Info Tool

Get system information (platform, memory, CPU, etc.).

Example:

{
  "name": "system_info",
  "arguments": {
    "detail": "full"
  }
}

πŸ”Œ Google ADK Integration

The project includes a Google ADK integration module that demonstrates:

  • Analytics Logging: Track tool usage

  • Fulfillment Handlers: Process Google Assistant requests (placeholder)

  • Usage Statistics: Get insights into tool usage

Enabling Google ADK

Set the environment variable:

export GOOGLE_ADK_ENABLED=true

Next Steps for Full Integration

  1. Set up Google Actions Project

    • Create a project in Google Cloud Console

    • Enable Actions API

    • Set up OAuth credentials

  2. Implement Webhook Server

    • Use Express.js or similar

    • Handle fulfillment requests

    • Connect to MCP server tools

  3. Deploy

    • Deploy to Google Cloud Functions or Cloud Run

    • Configure webhook URL in Actions Console

πŸ“š Best Practices Demonstrated

1. Type Safety

  • Full TypeScript implementation

  • Strict type checking enabled

  • Interface definitions for all tools

2. Security

  • Path validation (prevents directory traversal)

  • Input sanitization

  • Error message sanitization

3. Error Handling

  • Comprehensive try-catch blocks

  • Meaningful error messages

  • Graceful degradation

4. Code Organization

  • Separation of concerns

  • Modular tool architecture

  • Clear abstraction layers

5. Extensibility

  • Easy to add new tools (extend BaseTool)

  • Plugin-like architecture

  • Configuration-driven behavior

πŸ§ͺ Testing Your MCP Server

Using Claude Desktop

  1. Add to Claude Desktop configuration:

{
  "mcpServers": {
    "demo": {
      "command": "node",
      "args": ["/path/to/mcp-server-demo/dist/index.js"]
    }
  }
}
  1. Restart Claude Desktop

  2. The tools should be available in Claude

Using MCP Client

You can also test with an MCP client library or create a simple test script.

πŸŽ“ Learning Path

Beginner Tasks

  1. βœ… Understand the project structure

  2. βœ… Run the server and test tools

  3. βœ… Read through the code comments

  4. βœ… Modify calculator tool to add new operations

Intermediate Tasks

  1. Add a new tool (e.g., weather tool using an API)

  2. Implement resource caching

  3. Add tool usage rate limiting

  4. Create unit tests for tools

Advanced Tasks

  1. Implement full Google ADK webhook server

  2. Add authentication/authorization

  3. Implement tool chaining

  4. Add streaming responses

  5. Create a remote MCP server (HTTP transport)

πŸ“– Resources

🀝 Contributing

This is a learning project! Feel free to:

  • Add more example tools

  • Improve error handling

  • Add tests

  • Enhance documentation

πŸ“ License

MIT


Happy Learning! πŸš€

Available Tools

3 tools
calculatorB

Perform basic mathematical calculations (add, subtract, multiply, divide)

Inputs: operation (required), a (required), b (required).

file_operationsC

Read, write, and list files in the current workspace

Inputs: operation (required), path (required), content.

system_infoB

Get information about the system (platform, CPU, memory, uptime)

Inputs: detail.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: calculator handles math, file_operations manages files, and system_info provides system data. An agent can easily tell them apart based on their domains.

    Naming Consistency5/5

    All tool names follow a consistent snake_case pattern with clear noun-based naming (calculator, file_operations, system_info). There are no deviations or mixed conventions.

    Tool Count3/5

    With only 3 tools, the set feels thin for a 'Learning Project' server that might benefit from more educational or varied utilities. While each tool is distinct, the count is borderline low for broader scope.

    Completeness4/5

    The tools cover basic domains (math, file I/O, system info) well, but there are minor gaps for a learning context, such as missing tools for networking, data processing, or interactive tutorials that could enhance educational value.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A comprehensive learning project providing hands-on experience with Model Context Protocol (MCP) server development, featuring calculator and text utility tools for integration with Claude Desktop.
      1
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      A demonstration MCP server built with FastMCP v2.0 that provides basic mathematical calculations and greeting functionality. Features Docker containerization, comprehensive testing, and CI/CD automation for learning MCP development patterns.
      2
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A comprehensive MCP server that enables file operations, mathematical calculations with unit conversions, and system information retrieval. Provides secure access to local file system, calculator functions with statistics, and system monitoring capabilities.
      8 npm
      ISC