Skip to main content
Glama
gogouravr

FastMCP Demo

by gogouravr

FastMCP Demo - TypeScript MCP Server

A demonstration project to understand the Model Context Protocol (MCP) using TypeScript. This project implements a basic MCP server with tools, resources, and prompts.

What is MCP?

The Model Context Protocol (MCP) is a standardized protocol that enables AI assistants to securely access external data sources and tools. It provides a way for AI models to:

  • Tools: Execute functions and operations

  • Resources: Access data and information

  • Prompts: Use predefined prompt templates

Related MCP server: Hello World MCP Server

Project Structure

fast-mcp/
├── src/
│   └── index.ts          # Main MCP server implementation
├── dist/                 # Compiled JavaScript (generated)
├── package.json          # Project dependencies
├── tsconfig.json         # TypeScript configuration
└── README.md            # This file

Features

This demo server includes:

Tools

  • hello: A simple greeting tool that welcomes users

  • calculate: Performs basic arithmetic operations (add, subtract, multiply, divide)

Resources

  • demo://example: A simple text resource

  • demo://config: Server configuration in JSON format

Prompts

  • greet_user: Generates a greeting message for a user

  • explain_mcp: Provides an explanation of what MCP is

Setup

  1. Install dependencies:

    npm install
  2. Build the project:

    npm run build
  3. Run the server:

    npm start

    Or use the development mode with auto-reload:

    npm run dev

How MCP Works

Server Initialization

The server is created with capabilities for tools, resources, and prompts:

const server = new Server(
  { name: "fast-mcp-demo", version: "0.1.0" },
  {
    capabilities: {
      tools: {},
      resources: {},
      prompts: {},
    },
  }
);

Transport

This server uses stdio (standard input/output) transport, which means it communicates via stdin/stdout. This is the most common transport for MCP servers.

Request Handlers

Each capability requires request handlers:

  • ListToolsRequestSchema - Lists available tools

  • CallToolRequestSchema - Executes a tool

  • ListResourcesRequestSchema - Lists available resources

  • ReadResourceRequestSchema - Reads a resource

  • ListPromptsRequestSchema - Lists available prompts

  • GetPromptRequestSchema - Gets a prompt with arguments

Testing with MCP Clients

To test this server, you'll need an MCP client. Popular options include:

  1. Claude Desktop - Add the server to your MCP configuration

  2. MCP Inspector - A debugging tool for MCP servers

  3. Custom MCP Client - Build your own using the MCP SDK

Example Configuration (Claude Desktop)

Add to your Claude Desktop MCP settings:

{
  "mcpServers": {
    "fast-mcp-demo": {
      "command": "node",
      "args": ["/path/to/fast-mcp/dist/index.js"]
    }
  }
}

Learning Path

This project was built incrementally to understand MCP concepts:

  1. Initial Setup - TypeScript configuration and dependencies

  2. Basic Server - Simple server with hello tool

  3. Resources - Added resource reading capabilities

  4. Prompts - Added prompt templates

  5. Advanced Tools - Added calculate tool with error handling

Key Concepts

Tools

Tools are functions that the AI can call. They have:

  • A name and description

  • An input schema (JSON Schema)

  • Execution logic that returns results

Resources

Resources are data sources that can be read. They have:

  • A URI identifier

  • A name and description

  • A MIME type

  • Content that can be retrieved

Prompts

Prompts are template messages that can be used to guide AI interactions. They have:

  • A name and description

  • Optional arguments

  • Message templates

Next Steps

To extend this demo, consider:

  • Adding file system resources

  • Implementing authentication

  • Adding more complex tools (API calls, database queries)

  • Using different transports (SSE, HTTP)

  • Adding logging and error handling middleware

  • Implementing caching for resources

Resources

License

MIT

Available Tools

2 tools
calculateC

Perform basic arithmetic calculations

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

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 the full burden of behavioral disclosure. It states the tool performs calculations but doesn't mention any behavioral traits like error handling (e.g., division by zero), performance limits, or output format. This is a significant gap for a tool with potential side effects, scoring a 2 for inadequate transparency.

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 ('Perform basic arithmetic calculations') that is front-loaded and wastes no words. It directly conveys the core purpose without unnecessary elaboration, earning a 5 for optimal conciseness and structure.

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?

Given the tool's complexity (basic arithmetic with three parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain return values, error cases, or behavioral constraints, leaving gaps that could hinder an agent's correct invocation. This scores a 2 for insufficient contextual detail.

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, clearly documenting all three parameters (operation, a, b) with enums and descriptions. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline of 3 for adequate but not enhanced parameter information.

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 'Perform basic arithmetic calculations' clearly states the tool's function with a specific verb ('perform') and resource ('calculations'), distinguishing it from siblings like 'echo' and 'get_system_info'. However, it doesn't specify the exact operations (add, subtract, etc.) or 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 context, prerequisites, or exclusions, such as when to use it over other calculation methods or tools. This leaves the agent without usage direction, scoring a 2 for minimal guidance.

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

helloC

A simple greeting tool that says hello

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYesThe name to greet

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 the full burden of behavioral disclosure. It states the tool 'says hello', which implies a read-only output operation, but doesn't disclose any behavioral traits like whether it has side effects, requires authentication, has rate limits, or what format the greeting takes. The description is too minimal to provide meaningful behavioral context.

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 at just 7 words in a single sentence. It's front-loaded with the core purpose and contains zero wasted words. Every element of the description earns its place by communicating the essential function of the tool.

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?

Given that there are no annotations and no output schema, the description is incomplete for helping an agent understand how to properly use this tool. While the tool is simple (one parameter), the description doesn't explain what the tool returns, how the greeting is formatted, or any behavioral characteristics. For a tool with zero annotation coverage, this minimal description leaves significant 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 the 'name' parameter clearly documented as 'The name to greet'. The description doesn't add any parameter semantics beyond what the schema already provides. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no 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 as 'A simple greeting tool that says hello', which specifies the verb ('says hello') and resource (greeting). It distinguishes from the sibling 'calculate' tool by focusing on greetings rather than calculations. However, it doesn't explicitly differentiate from potential other greeting tools beyond the sibling context.

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 specific contexts, prerequisites, or exclusions. The only implied usage is for greeting purposes, but this is too vague to help an agent make informed decisions about tool selection.

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. 2 tool updates
    • First observedcalculate
    • First observedhello

TDQS

B3/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have completely distinct purposes: 'calculate' handles arithmetic operations, while 'hello' provides a greeting. There is no overlap or ambiguity between these functions, making it easy for an agent to select the correct tool.

Naming Consistency5/5

Both tool names follow a consistent pattern of using simple, descriptive verbs ('calculate', 'hello') without any mixing of conventions like camelCase or snake_case. The naming is straightforward and predictable.

Tool Count2/5

With only two tools, the server feels thin and under-scoped for a general-purpose demo. While the tools are distinct, the count is too low to meaningfully cover a domain or provide a coherent set of operations, limiting utility.

Completeness1/5

The server lacks a clear domain, making it impossible to assess coverage meaningfully. The tools are trivial and unrelated (arithmetic and greeting), offering no cohesive workflow or lifecycle, which severely limits agent functionality.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    D
    quality
    D
    maintenance
    A minimal Model Context Protocol server in TypeScript that demonstrates MCP-compliant resources and tools for LLMs, featuring simple resources and a basic tool that echoes messages or returns greetings.
    1
    5
    Apache 2.0
  • -
    license
    B
    quality
    Not graded
    maintenance
    A boilerplate project for quickly developing Model Context Protocol (MCP) servers using TypeScript SDK. Includes example tools for calculations and greetings, plus system information resources.
    3
    -
  • F
    license
    B
    quality
    D
    maintenance
    A boilerplate project for quickly developing Model Context Protocol (MCP) servers using TypeScript SDK. Includes example tools like calculator and greeting functions, plus system information resources.
    3
    -