
openai_mcp
提供与 OpenAI 模型交互的本地接口,支持工具增强推理。
Repository Info
About This Server
提供与 OpenAI 模型交互的本地接口,支持工具增强推理。
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 MCP
This tool provides a local interface for interacting with OpenAI models that can call tools hosted on a Model Context Protocol (MCP) server. It enables tool-augmented reasoning through a modular and extensible architecture.
How it works
- The client passes your query to the OpenAI API.
- The OpenAI API determines whether a tool is required to fulfill the request.
- If needed, it responds with a tool call request.
- The client then runs the requested tool using the local MCP server.
- The result is sent back to the OpenAI API for processing.
- The OpenAI API determines if the query has been fullfilled or if further tools calls are needed in which case steps 3-5 are repeated until the task is complete.
- The API returns the fully formatted response, which is displayed to the user.
Set-up
Built with Python 3.12.6
Ensure you are in the project directory openai_mcp
Virtual Environment with Automatic Setup (Optional)
Change source to the projects virtual environment and automatically install requirements:
# Windows
setup_env.bat
# Linux
chmod +x setup_env.sh
source setup_env.sh
Install Requirements
Thess steps should be complete already if you ran the setup_env
- Install required Python Packages:
pip install -r requirements.txt - Clone MCP Servers
git clone https://github.com/modelcontextprotocol/servers.git - Install required Node Packages and Build the Servers:
cd servers npm install npm run build
Environment Variables
Create a .env file in the openai_mcp directory with:
OPENAI_API_KEY=your_openai_api_key
Note: Obtain your API key from the OpenAI dashboard
Using the Agent with MCP Tools Available
Configure MCP Servers
Servers can be configured in config.py based on each ones documentation at https://github.com/modelcontextprotocol/servers/tree/main/src
Already Configured Servers
Servers can be disabled by setting their load_tools_to_client to False
- Filesystem - This MCP Server provides tools cabable of interacting with the file system based on the configured allowed directories
- Add any paths that the tools should be able to access to the
accessible_dirslist, paths to the User's local(not OneDrive) Desktop and Documents directory are already included
- Add any paths that the tools should be able to access to the
- Puppeteer - This MCP Server provides tools cabable of performing tasks within a Web Browser
- Adjust if the browser is run in headless mode and what dimensions to set the window to
- Memory - This MCP Server provides persistent memory capabilities using a local knowledge graph, allowing the system to remember user-specific information across interactions
-
Adjusting the
MEMORY_BEHAVIORwill allow for specifiyingMemorybehaviorExample
Follow these steps for each interaction:-
User Identification:
- You should assume that you are interacting with default_user
- If you have not identified default_user, proactively try to do so.
-
Memory Retrieval:
- Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph
- Always refer to your knowledge graph as your "memory"
-
Memory
- While conversing with the user, be attentive to any new information that falls into these categories: a) Basic Identity (age, gender, location, job title, education level, etc.) b) Behaviors (interests, habits, etc.) c) Preferences (communication style, preferred language, etc.) d) Goals (goals, targets, aspirations, etc.) e) Relationships (personal and professional relationships up to 3 degrees of separation)
-
Memory Update:
- If any new information was gathered during the interaction, update your memory as follows: a) Create entities for recurring organizations, people, and significant events b) Connect them to the current entities using relations b) Store facts about them as observations
-
-
- Fetch - This MCP Server enables the retrieval and processing of web content, converting HTML to markdown, and allowing models to fetch and read data in chunks from web pages
- Git - This MCP Server allows for basic Git interaction
- Updating the
ACCESSIBLE_REPOwill let the MCP Server work within that path
- Updating the
- Sequential_Thinking - This MCP Server specifies that the LLM should use a structured thinking path to solve promplems in a dynamic and reflective way
- Time - This MCP Server allows for knowing the current time and performing Timezone Conversion
- Updating the configured
TIMEZONEwill change what TZ the server uses to answer (Setting it toNonewill result in using UTC)
- Updating the configured
Run the MCP Client
If verbose logging is needed, set VERBOSE_CHAT_LOG in config.py to True
- Set the desired
OPENAI_MODELinconfig.py,o3-minirecommended Note: The model must be listed inmodules.openai_utils.MODEL_PRICINGor one will be selected for you. - Adjust
MAX_CALLS_PER_QUERYas needed inconfig.py - Run
python main.pyin the terminal - Interact with the Client as desired
- Send
quitas a query to close the Client and connections
Cleanup
Removing venv and servers Repo
Remove the servers repository and venv, making branch cleanup easier
# Windows
cleanup_env.bat
# Linux
chmod +x cleanup_env.sh
./cleanup_env.sh
Quick Start
Clone the repository
git clone https://github.com/bbarrington0099/openai_mcpInstall dependencies
cd openai_mcp
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.