Skip to main content
Glama
aakankshagupta18

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)

ParametersJSON Schema
NameRequiredDescriptionDefault
operationYesThe mathematical operation to perform
aYesFirst number
bYesSecond number

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'perform basic mathematical calculations' implies a read-only computation, it doesn't explicitly state whether this tool has side effects, requires permissions, handles errors (like division by zero), or has rate limits. The description is minimal and lacks behavioral context beyond the basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without any wasted words. It's appropriately sized for a simple tool and front-loaded with the core purpose. Every part of the sentence earns its place by specifying the operations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (basic math operations) and the absence of an output schema, the description is minimally complete. It covers what the tool does but lacks details on return values, error handling, or usage context. With no annotations and no output schema, it should ideally provide more behavioral insight, but for this simple tool, it's adequate though with clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear documentation for all three parameters (operation, a, b). The description adds no additional parameter semantics beyond what's in the schema, such as format examples or constraints. According to the rules, with high schema coverage (>80%), the baseline is 3 even without param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs (add, subtract, multiply, divide) and the resource (mathematical calculations). It distinguishes itself from sibling tools like file_operations and system_info by focusing on arithmetic operations. However, it doesn't explicitly differentiate from potential alternative calculation tools, keeping it at a 4 rather than a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, limitations, or context for choosing this calculator over other methods. With sibling tools like file_operations and system_info available, there's no indication of when mathematical calculations are appropriate versus those other operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

file_operationsC

Read, write, and list files in the current workspace

ParametersJSON Schema
NameRequiredDescriptionDefault
operationYesThe file operation to perform
pathYesFile or directory path (relative to workspace)
contentNoContent to write (required for write operation)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions the three operation types, it doesn't describe what 'read' returns, how 'write' handles existing files, what 'list' includes, what 'info' provides, workspace boundaries, error conditions, or permission requirements. This is inadequate for a multi-operation tool with mutation capabilities.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (7 words) and front-loaded with all essential information. Every word earns its place by covering the core functionality without redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a multi-operation tool with write capabilities and no annotations or output schema, the description is insufficient. It doesn't explain return values, error handling, workspace constraints, or behavioral differences between operations. The agent lacks critical information needed to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. The baseline score of 3 reflects adequate schema coverage without description enhancement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs (read, write, list) and resource (files in current workspace). It distinguishes this tool from its siblings (calculator, system_info) by focusing on file operations. However, it doesn't explicitly differentiate between the different operation types within the tool itself.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives or when specific operations are appropriate. There's no mention of prerequisites, constraints, or comparison with other file management approaches. The agent must infer usage from the operation parameter alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

system_infoB

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

ParametersJSON Schema
NameRequiredDescriptionDefault
detailNoLevel of detail (basic or full)

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it indicates a read operation ('Get'), it lacks details on permissions needed, rate limits, error conditions, or what the return format looks like (e.g., structured data vs. raw text). This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Get information about the system') and lists specific components (platform, CPU, memory, uptime). There is zero waste or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one optional parameter with full schema coverage) and no output schema, the description is adequate but incomplete. It covers the purpose well but lacks behavioral context and usage guidelines, which are important for an agent to use it effectively without annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description does not mention the 'detail' parameter or its semantics. However, the input schema has 100% description coverage, with a clear enum for 'basic' and 'full', so the schema does the heavy lifting. The baseline is 3 when schema coverage is high, even without param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'information about the system', specifying the exact scope: platform, CPU, memory, and uptime. It distinguishes itself from sibling tools like 'calculator' and 'file_operations' by focusing on system diagnostics rather than calculations or file management.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description does not mention any prerequisites, exclusions, or specific contexts for usage, leaving the agent to infer based on the tool's name and purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 3 tool updatesv1.0.0
    • First observedcalculator
    • First observedfile_operations
    • First observedsystem_info

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 issues

Related MCP Connectors

Related MCP Servers

  • F
    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
    -
  • 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.
    9 npm
    ISC