The AI MCP Server is an implementation that supports OpenAI and Mistral models using the Vercel AI SDK. This server allows you to access powerful language models through a standardized Model Context Protocol interface, making it easier to build AI-powered applications.
Before installing the MCP server, ensure you have:
git clone https://github.com/yourusername/openai-mcp-server.git
cd openai-mcp-server
npm install
Set up environment variables:
Create a .env
file in the root directory with the following variables:
OPENAI_API_KEY=your_openai_api_key_here
MISTRAL_API_KEY=your_mistral_api_key_here
PORT=3000 # Optional, defaults to 3000
npm start
Once the server is running, it will be available at http://localhost:3000
(or the port you specified).
You can send requests to the server using any MCP-compatible client. The server exposes endpoints for both OpenAI and Mistral models.
The MCP server provides the following endpoints:
/v1/mcp
- The main MCP endpoint for all model interactionsHere's an example of how to make a request to the server:
const response = await fetch('http://localhost:3000/v1/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'gpt-4-turbo', // or 'mistral-large-latest'
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello, how are you?' }
],
stream: true, // Optional, for streaming responses
temperature: 0.7 // Optional, controls randomness
})
});
The server accepts the following configuration options in your request:
model
: The model to use (e.g., 'gpt-4-turbo', 'mistral-large-latest')messages
: Array of message objects with 'role' and 'content'stream
: Boolean indicating whether to stream the responsetemperature
: Controls randomness (0-1)max_tokens
: Maximum number of tokens to generatetools
: Array of tool definitions for function calling (OpenAI only).env
fileIf you encounter issues, check the server logs for more detailed error information.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "vercel-ai" '{"command":"npx","args":["-y","mcp-vercel-ai"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"vercel-ai": {
"command": "npx",
"args": [
"-y",
"mcp-vercel-ai"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"vercel-ai": {
"command": "npx",
"args": [
"-y",
"mcp-vercel-ai"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect