Cover image
Try Now
2024-12-05

3 years

Works with Finder

1

Github Watches

1

Github Forks

1

Github Stars

MCP Server-Client Example

This project demonstrates a basic implementation of the Model Context Protocol (MCP) using the TypeScript SDK. It includes both a server and client implementation that communicate over stdio transport.

Overview

The example includes:

  • An MCP server that provides access to resources
  • An MCP client that connects to the server and requests resources
  • Basic resource listing and reading functionality

Prerequisites

  • Node.js (v16 or higher)
  • npm

Installation

Clone the repository and install dependencies:

npm install

Project Structure

src/
  ├── index.ts    # Server implementation
  └── client.ts   # Client implementation

Running the Example

You'll need to run the server and client in separate terminal windows.

  1. Start the server:
npm run start:server
  1. In a new terminal, start the client:
npm run start:client

The client will:

  1. Connect to the server
  2. Request a list of available resources
  3. Read the content of an example resource

Server Capabilities

The server currently supports:

  • Resource listing
  • Resource reading
  • Basic error handling for unknown resources

Available Resources

The example server provides access to:

  • file:///example.txt: A simple text resource

Development

Scripts

  • npm run start:server: Starts the MCP server
  • npm run start:client: Starts the MCP client

Adding New Resources

To add new resources, modify the ListResourcesRequestSchema handler in src/index.ts:

server.setRequestHandler(ListResourcesRequestSchema, async () => {
  return {
    resources: [
      {
        uri: "file:///example.txt",
        name: "Example Resource",
      },
      // Add new resources here
    ],
  };
});

Dependencies

  • @modelcontextprotocol/sdk: MCP TypeScript SDK
  • ts-node: TypeScript execution environment
  • typescript: TypeScript compiler

License

ISC

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • https://hubeiqiao.com
  • IT problem solver with clear, step-by-step guidance.

  • Andris Teikmanis
  • Latvian GPT assistant for developing GPT applications

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Navid RezaeiSarchoghaei
  • Professional Flask/SQLAlchemy code guide. Follow: https://x.com/navid_re

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Jan Meindl
  • Builds new GPTs

  • XLwebDev.com
  • PR Professional: Guiding You to Get Media Placements and Publicity Quickly and Effectively

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • OffchainLabs
  • Implementación de la prueba de estaca Ethereum

  • oatpp
  • Implementación del protocolo de contexto modelo de Anthrope para OAT ++

  • huahuayu
  • Una puerta de enlace de API unificada para integrar múltiples API de explorador de blockchain similar a Esterscan con soporte de protocolo de contexto modelo (MCP) para asistentes de IA.

  • deemkeen
  • Controle su MBOT2 con un combo de potencia: MQTT+MCP+LLM

  • zhaoyunxing92
  • 本项目是一个钉钉 MCP (Protocolo del conector de mensajes )服务 , 提供了与钉钉企业应用交互的 API 接口。项目基于 Go 语言开发 支持员工信息查询和消息发送等功能。 支持员工信息查询和消息发送等功能。

    Reviews

    5 (1)
    Avatar
    user_p4mC7rkm
    2025-04-15

    The Remote MCP Server on Cloudflare by kalepail has been a game-changer for our remote operations. The seamless integration and robust performance have exceeded our expectations. Highly recommend checking it out at https://mcp.so/server/stellar-mcp-server/kalepail for anyone needing a reliable server solution.