MCP-Server-and-Client

Pieter1821/MCP-Server-and-Client

3.2

If you are the rightful owner of MCP-Server-and-Client and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Node.js project implementing a Model Context Protocol (MCP) server and client for resource and tool management, user data handling, and prompt-based operations.

MCP Server and Client

A Node.js project implementing a Model Context Protocol (MCP) server and client for resource and tool management, user data handling, and prompt-based operations.

Features

  • Interactive CLI for Model Context Protocol (MCP) server
  • Tool execution with dynamic input prompts
  • Resource and resource template reading with parameter substitution
  • Prompt selection and execution
  • Integrated Google Gemini API for text generation

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/<your-username>/<your-repo-name>.git
    cd <your-repo-name>
    
  2. Install dependencies:

    npm install
    

    The following packages will be installed:

    • @inquirer/prompts
    • @modelcontextprotocol/sdk
    • dotenv
    • zod
    • @modelcontextprotocol/inspector (dev)
    • @types/node (dev)
    • ts-node (dev)
    • tsx (dev)
    • typescript (dev)
  3. Build the server:

    npm run server:build
    

Usage

  1. Install dependencies and set up your .env file with GEMINI_API_KEY.
  2. Run the client:
    npm run build
    node build/client.js
    
  3. Follow the CLI prompts to interact with tools, resources, and prompts.

Run the server (development)

npm run server:dev

Run the client

  • The client connects to the server using the built files.
  • You can run the client code in src/client/client.ts (TypeScript) or use the built JS in build/client/client.js.

Scripts

  • npm run server:build — Compile TypeScript to JavaScript
  • npm run server:build:watch — Watch and compile on changes
  • npm run server:dev — Run the server in development mode
  • npm run server:inspect — Run the server with MCP Inspector

Project Structure

ā”œā”€ā”€ build/
│   ā”œā”€ā”€ server.js
│   └── client/
│       └── client.js
│   └── data/
│       └── users.json
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ server.ts
│   └── client/
│       └── client.ts
│   └── data/
│       └── users.json
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Create a new Pull Request

License

This project is licensed under the ISC License.

Contact

For questions or support, open an issue on GitHub.