fsalviati/MCP-server
3.2
If you are the rightful owner of MCP-server 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.
This repository provides a simple setup for a Model Context Protocol (MCP) server and client, demonstrating tool registration and interaction using TypeScript and OpenAI's API.
MCP Server & Client Example
This repository demonstrates a simple Model Context Protocol (MCP) setup with:
- a TypeScriptâbased MCP server that registers tools (e.g.
create-user
) - a companion client that launches the server via stdio, lists available tools/prompts/resources, and lets you interact with them
- integration with OpenAIâs Chat Completions API for naturalâlanguage handling
âšď¸ By default this example uses OpenAI (GPTâ3.5âturbo). You can swap in any other AI providerâjust update the import/provider call in
src/client.ts
.
Features
- Server (
src/server.ts
)- Registers one or more âtoolsâ via
server.registerTool(...)
- Exposes them over JSONâRPC (stdio transport) for clients to call
- Registers one or more âtoolsâ via
- Client (
src/client.ts
)- Spawns your TypeScript server via
npx tsx src/server.ts
- Lists tools, resources, prompts from the server
- Lets you âQueryâ with free text: automatically calls OpenAI + MCP tools
- Handles tool calls and prints back results in your terminal
- Spawns your TypeScript server via
Getting Started
Prerequisites
- Node.js âĽâŻ18
- npm or yarn
Installation
git clone https://github.com/yourâusername/mcp-server-and-client.git
cd mcp-server-and-client
npm install
# or
yarn install