OpenAI Integration with MCP
@Robinson777-prog
OpenAI Integration with MCP について
4-openai-integration
基本情報
設定
ツール
ツールは検出されませんでした
ツールは README から自動的に抽出されます。メンテナーは ## Tools という見出しの下に記載することで、このタブに反映できます。
概要
What is OpenAI Integration with MCP?
This example demonstrates how to integrate the Model Context Protocol (MCP) with OpenAI’s API, allowing OpenAI to dynamically use tools exposed by an MCP server. It is intended for developers building AI‑powered applications that need to access backend knowledge bases or other tool‑based systems.
How to use OpenAI Integration with MCP?
Install the required dependencies, set your OpenAI API key in a .env file, and run the client with python client.py. The MCP server is automatically launched as a subprocess via stdio transport, so no separate server startup is needed. For a split client‑server architecture, switch to SSE transport as described in the documentation.
Key features of OpenAI Integration with MCP
- Exposes a
get_knowledge_basetool that retrieves Q&A pairs - Converts MCP tools to OpenAI’s function‑calling format
- Handles tool selection, execution, and result integration automatically
- Uses stdio transport for single‑process communication
- Provides a standardized, secure bridge between AI and backend systems
- Includes an example knowledge base of company policy Q&A
Use cases of OpenAI Integration with MCP
- Empower OpenAI to answer employee questions by querying an internal knowledge base
- Automate customer support by giving OpenAI access to a help‑desk tool database
- Build AI assistants that retrieve dynamic data from any MCP‑compatible backend
- Prototype and test MCP integrations with OpenAI before deploying to production
FAQ from OpenAI Integration with MCP
What transport does this example use?
It uses stdio transport, meaning the client and server run in the same process and the client launches the server as a subprocess. If you need separate applications (e.g., running the server on a different machine), use the SSE (Server‑Sent Events) transport instead.
How does OpenAI execute the tools?
OpenAI’s function‑calling mechanism works through four steps: the MCP client registers tools as OpenAI functions, OpenAI chooses which tool to use based on the query, the client executes the tool via MCP, and OpenAI incorporates the result into its final response.
What role does MCP play in this integration?
MCP acts as a standardized, secure bridge between AI models and your backend systems. It abstracts away backend complexity, provides a consistent interface for tool interactions, and lets you control exactly which tools and data are exposed.
What data does the example knowledge base contain?
It contains Q&A pairs about company policies stored in a JSON file (data/kb.json). The MCP server retrieves these pairs through the get_knowledge_base tool.
Do I need to run the MCP server separately?
No. With the stdio transport used here, the client automatically starts the server as a subprocess. For an SSE‑based setup, you would run the server independently.
「AI とエージェント」の他のコンテンツ
欢迎来到 智言平台
Shy2593666979AgentChat 是一个基于 LLM 的智能体交流平台,内置默认 Agent 并支持用户自定义 Agent。通过多轮对话和任务协作,Agent 可以理解并协助完成复杂任务。项目集成 LangChain、Function Call、MCP 协议、RAG、Memory、HITL、Skill、Milvus 和 ElasticSearch 等技术,实现高效的知识检索与工具调用,使用 FastAPI 构建高性能后端服务。
21st.dev Magic AI Agent
21st-devIt's like v0 but in your Cursor/WindSurf/Cline. 21st dev Magic MCP server for working with your frontend like Magic
LinkedIn MCP Server
stickerdanielOpen-source MCP server for LinkedIn. Give Claude and any MCP-compatible AI agent access to profiles, companies, jobs, and messages.
Just Prompt - A lightweight MCP server for LLM providers
dislerjust-prompt is an MCP server that provides a unified interface to top LLM providers (OpenAI, Anthropic, Google Gemini, Groq, DeepSeek, and Ollama)
MCP Client for Ollama (ollmcp)
joniglHarness the power of local LLMs with this TUI MCP Client for Ollama. Featuring all core MCP primitives (tools, prompts, resources), agent mode, multi-server, model switching, streaming responses, human-in-the-loop, thinking mode, model params config, system prompts, and saved pre
コメント