openai-mcp-client

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.

50
6

Summary

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.

Setup Guide

  • Ensure Deno v2 is installed.
  • Use deno install to install the necessary dependencies.
  • Duplicate .env.example to .env and configure the environment variables, including selecting an MCP server from the official list.
  • Execute deno run dev to launch the application.

Warning

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.

Limitations

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.

Notes

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.

Repository

RE
ResoluteError

ResoluteError/openai-mcp-client

Created

December 12, 2024

Updated

March 27, 2025

Language

TypeScript

Category

AI