
openai tools and mcp examples
Examples of OpenAI tool calls and Model Context Protocol (MCP)
Repository Info
About This Server
Examples of OpenAI tool calls and Model Context Protocol (MCP)
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
OpenAI Tool Calls and MCP (Model Context Protocol) Examples
A TypeScript project demonstrating both OpenAI function calling capabilities and Model Context Protocol (MCP) implementation.
Setup
- Clone the repository
- Install dependencies:
npm install
- Configure your OpenAI API key in the
.envfile:
OPENAI_API_KEY=your_api_key_here
Running the Examples
OpenAI Tool Calls Example
npm run dev
MCP Server Example
ts-node src/mcp-server.ts
MCP Client Example
ts-node src/mcp-client.ts
How It Works
This project demonstrates:
OpenAI Tool Calls
- Setting up a simple calculator tool (function)
- Sending a request to OpenAI with the tool definition
- Handling the tool call response
- Sending a follow-up request with the tool result
Model Context Protocol (MCP)
- Implementing an MCP server that exposes calculator tools
- Creating an MCP client that connects to the server
- Calling tools through the MCP protocol
- Handling responses between client and server
The code is heavily commented to explain each step of the process.
Learning Resources
- OpenAI Tools Documentation
- Model Context Protocol (MCP) Documentation
Quick Start
Clone the repository
git clone https://github.com/nareshtank001/openai-tools-and-mcp-examplesInstall dependencies
cd openai-tools-and-mcp-examples
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.