Skip to content

Adaptation of the Anthropic MCP Course to use it with OpenAI API

lbatresm/anthropic-mcp-course-openai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Chat

MCP Chat is a command-line application that enables interactive chat with models via the OpenAI API. It supports document retrieval, command-based prompts, and extensible tools via the MCP (Model Control Protocol) architecture.

Requirements

  • Python 3.10+
  • OpenAI API Key

Setup

Step 1: Configure environment variables

  1. Create or edit the .env file in the project root and ensure the following variables are defined:
OPENAI_API_KEY=""      # Your OpenAI key
OPENAI_MODEL="gpt-4o-mini"  # Optional: default model

Step 2: Install dependencies

Option 1: Setup with uv (recommended)

uv is a fast Python package installer and resolver.

  1. Install uv if you don't have it:
pip install uv
  1. Create and activate a virtual environment:
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
uv pip install -e .
  1. Run the project
uv run main.py

Option 2: Setup without uv

  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
pip install openai python-dotenv prompt-toolkit "mcp[cli]==1.8.0"
  1. Run the project
python main.py

Usage

Basic interaction

Type your message and press Enter to chat with the model.

Document retrieval

Use the @ symbol followed by the document ID to include its content in your query:

> Tell me about @deposition.md

Commands

Use the / prefix to execute commands defined in the MCP server:

> /summarize deposition.md

Commands support tab-completion.

Development

Add new documents

Edit mcp_server.py to add documents to the docs dictionary.

Implement MCP features

To fully implement MCP:

  1. Complete the TODOs in mcp_server.py
  2. Implement the missing functionality in mcp_client.py

Linting and type checking

No linting or type checking is implemented.

About

Adaptation of the Anthropic MCP Course to use it with OpenAI API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages