This repository demonstrates using the Model Context Protocol with OpenAI to build a chat-based agent. It provides a starting point for projects, but users should be aware of potential token usage costs.
This repository provides a basic example of using the Model Context Protocol (MCP) with OpenAI's API to build a simple chat-based agent. It serves as a starting point for projects leveraging MCP for context management.
deno install to install the necessary dependencies..env.example to .env and configure the environment variables, including selecting an MCP server from the official list.deno run dev to launch the application.The application appends all chat messages, sending the entire conversation to the server, which can lead to high token usage and costs depending on the conversation length, model, and context size.
The current implementation only supports tool call responses of the text type. Support for other resource types can be added in applyToolCallIfExists within src/openai-utils.ts.
Your latest messages are saved in messages.json for debugging. These messages are overwritten on each run, so back them up if needed. Setting DEBUG to true in .env enables debug mode, providing more detailed information about messages and tool calls.
ResoluteError/openai-mcp-client
December 12, 2024
March 27, 2025
TypeScript