demo-ts-mcp-client-server

demo-ts-mcp-client-server

3.5

This project demonstrates a fundamental client-server interaction using the Model Context Protocol (MCP) to extend AI model capabilities.

Demo MCP Basic is a project that showcases the integration of AI models with external tools via the Model Context Protocol (MCP). The server acts as an MCP provider, offering basic calculation tools, while the client uses the AI SDK to interact with a Google AI model and connect to the MCP server. This setup allows AI models to access custom functionalities hosted on an MCP server, enhancing their capabilities. The project requires Node.js, npm, and a Google AI API Key for setup. It includes scripts for building and running the server and client in both production and development modes. The client script demonstrates connecting to the MCP server, fetching tools, configuring the AI model, executing prompts, and outputting results.

Features

  • Securely extends AI model capabilities with external tools.
  • Demonstrates client-server interaction using MCP.
  • Includes scripts for building and running in different modes.
  • Supports Google AI models via API Key or Vertex AI.
  • Illustrates tool fetching and AI model configuration.

MCP Tools

  • Addition Tool: Performs addition operations.
  • Subtraction Tool: Performs subtraction operations.

Usage with Different Platforms

Node.js

bash
npm run build
npm run start

Google AI

bash
# Ensure .env is configured with your API keys
npm run start:client

Frequently Asked Questions

What is the purpose of the MCP server?

The MCP server provides external tools that can be used by AI models to extend their capabilities.

How do I configure the AI model?

The AI model is configured using environment variables set in the .env file, which include API keys and project IDs.