openai-agents-sdk-mcp

openai-agents-sdk-mcp

Provides MCP tools to list and search OpenAI Agents SDK documentation, enabling LLMs to retrieve documentation topics and content via natural language queries.

Category
访问服务器

README

OpenAI Agents SDK MCP Tool

A Model Context Protocol (MCP) server that provides documentation for the OpenAI Agents SDK by extracting and indexing content from the official documentation website: https://openai.github.io/openai-agents-python/

This package can be installed as a Python library and used with any MCP-compatible LLM client (Claude Desktop, VS Code, Cursor, etc.).

Installation

From PyPI (Recommended)

pip install openai-agents-sdk-mcp

From Source

git clone https://github.com/gavinz0228/openai-agents-sdk-mcp.git
cd openai-agents-sdk-mcp
pip install -e .

See INSTALLATION.md for detailed installation instructions.

Overview

This project provides both a standalone CLI tool and an MCP server that allows LLMs to access and query the OpenAI Agents SDK documentation intelligently.

Quick Start (MCP Server)

  1. Install the package:

    pip install openai-agents-sdk-mcp
    
  2. Set up API key:

    export OPENAI_API_KEY="sk-your-api-key-here"
    
  3. Configure your MCP client (e.g., Claude Desktop):

    {
      "mcpServers": {
        "openai-agents-sdk-docs": {
          "command": "openai-agents-sdk-mcp",
          "env": {
            "OPENAI_API_KEY": "sk-your-api-key-here"
          }
        }
      }
    }
    
  4. Start using it - Ask your LLM:

    • "List all OpenAI Agents SDK documentation topics"
    • "Get documentation for handoffs"
    • "How do I use streaming in OpenAI Agents?"

See INSTALLATION.md and MCP_CONFIGURATION.md for detailed setup instructions.

Features

1. MCP Server (Primary Interface)

Exposes two tools for LLMs:

  • list_documentation_topics: Get a complete list of all available documentation topics with their URLs
  • get_documentation: Search for and retrieve documentation using natural language queries

2. Automatic Documentation Indexing

  • Fetches and parses the OpenAI Agents SDK documentation website
  • Extracts all navigation links and topics
  • Creates a structured JSON map of topics to URLs
  • Saves to docs_index.json for quick access

2. Smart Index Management

The tool automatically manages the documentation index with intelligent caching:

  • Missing Index Detection: Automatically fetches fresh index if docs_index.json doesn't exist
  • Staleness Check: Refreshes index if older than 1 day (configurable)
  • Link Validation: Verifies all documentation links are working
  • Broken Link Recovery: Automatically re-fetches index if any links are broken

3. AI-Powered Feature Search

Uses OpenAI's GPT-4o-mini to intelligently match user queries to documentation:

  • Accepts natural language queries (e.g., "how do I trace my agent")
  • Finds the closest matching documentation topic
  • Fetches and displays relevant documentation content
  • Works with fuzzy matching and conversational queries

Installation

  1. Clone the repository:
git clone https://github.com/gavinz0228/openai-agents-sdk-mcp.git
cd openai-agents-sdk-mcp
  1. Install the package:
pip install -e .
  1. Configure API key: Create a .env file in your working directory:
OPENAI_API_KEY=sk-your-api-key-here

Or set as environment variable:

export OPENAI_API_KEY="sk-your-api-key-here"

See INSTALLATION.md for more installation options.

Usage

MCP Server (Recommended)

The MCP server allows LLMs to access the documentation through standardized tool calls.

Start the Server

openai-agents-sdk-mcp

Or if running from source:

python -m openai_agents_sdk_mcp.server

Configure MCP Client

Add to your MCP client configuration (e.g., Claude Desktop's config):

{
  "mcpServers": {
    "openai-agents-sdk-docs": {
      "command": "openai-agents-sdk-mcp"
    }
  }
}

Or use the absolute path if installed in a virtual environment:

{
  "mcpServers": {
    "openai-agents-sdk-docs": {
      "command": "/path/to/.venv/bin/openai-agents-sdk-mcp"
    }
  }
}

Available MCP Tools

list_documentation_topics

  • Lists all available documentation topics
  • Optional parameter: force_refresh (boolean) - Force refresh the index

Example:

{
  "name": "list_documentation_topics",
  "arguments": {
    "force_refresh": false
  }
}

get_documentation

  • Search and retrieve documentation for a specific feature
  • Parameters:
    • query (string, required) - Feature name or natural language question
    • include_content (boolean, optional) - Whether to include full content (default: true)

Example:

{
  "name": "get_documentation",
  "arguments": {
    "query": "handoffs",
    "include_content": true
  }
}

Test the Server

python test_mcp.py

Command Line Interface

Use the CLI tool for quick documentation queries:

# List all documentation topics
openai-agents-docs

# Search for specific documentation
openai-agents-docs "handoffs"
openai-agents-docs "streaming"
openai-agents-docs "how to use guardrails"

As a Python Library

from openai_agents_sdk_mcp import (
    load_or_refresh_index,
    get_documentation_for_feature
)

# Load documentation index
doc_map = load_or_refresh_index()
print(f"Found {len(doc_map)} topics")

# Find documentation for a feature
topic, url = get_documentation_for_feature("handoffs")
if topic:
    print(f"Topic: {topic}")
    print(f"URL: {url}")

Standalone CLI Tool (Legacy)

If running from source without installation:

Generate/Refresh Documentation Index

python openai_agents_sdk_mcp.py

This will:

  • Fetch the latest documentation structure
  • Extract all topics and links
  • Save to docs_index.json
  • Display all available topics

Search for Documentation

python openai_agents_sdk_mcp.py "feature name or query"

Examples:

# Simple feature name
python openai_agents_sdk_mcp.py "handoffs"

# Natural language query
python openai_agents_sdk_mcp.py "how do I stream responses"

# Topic search
python openai_agents_sdk_mcp.py "tracing and debugging"

# Multiple words
python openai_agents_sdk_mcp.py "realtime voice"

The tool will:

  1. Load or refresh the documentation index (if stale)
  2. Use AI to find the best matching topic
  3. Display the matched topic and URL
  4. Fetch and show a preview of the documentation content

How It Works

Index Management

# The index is automatically managed:
# 1. Checks if docs_index.json exists
if not exists:
    fetch_fresh_index()

# 2. Checks if index is older than 1 day
if age > 1_day:
    fetch_fresh_index()

# 3. Validates all links are working
if broken_links_found:
    fetch_fresh_index()

AI-Powered Matching

The tool uses OpenAI's GPT-4o-mini to match user queries to documentation topics:

  1. Loads all available topics from the index
  2. Sends user query + topic list to the LLM
  3. LLM identifies the most relevant topic
  4. Returns the matching topic and URL

This provides intelligent matching even for:

  • Typos and misspellings
  • Natural language questions
  • Partial or fuzzy matches
  • Related concepts

Configuration

Constants (in openai_agents_sdk_mcp.py)

DOCS_INDEX_FILE = "docs_index.json"  # Index file name
INDEX_MAX_AGE_DAYS = 1               # Maximum age before refresh

Environment Variables

  • OPENAI_API_KEY - Required for AI-powered search functionality

Files

  • server.py - MCP server implementation
  • openai_agents_sdk_mcp.py - Core functionality and CLI tool
  • test_mcp.py - Test script for the MCP server
  • mcp_config.json - Example MCP client configuration
  • docs_index.json - Cached documentation index (auto-generated)
  • requirements.txt - Python dependencies
  • .env - Environment variables (create this)
  • .gitignore - Git ignore rules (protects API key)

Dependencies

  • requests - HTTP requests for fetching web pages
  • beautifulsoup4 - HTML parsing
  • lxml - XML/HTML parser
  • openai - OpenAI API client for AI-powered search
  • python-dotenv - Environment variable management
  • mcp - Model Context Protocol SDK

Example Output

Index Generation

Fetching OpenAI Agents SDK documentation index...
Fetching fresh documentation index...
Index refreshed with 80 topics and saved to 'docs_index.json'.

Found 80 documentation topics/features:
...

Feature Search

Searching for documentation on: handoffs

Loaded existing index with 80 topics.
Verifying documentation links...
  ✓ All links are valid
✓ Found matching topic: Handoffs
  URL: https://openai.github.io/openai-agents-python/handoffs/

Fetching documentation content...
================================================================================
Handoffs - OpenAI Agents SDK
...

License

This project is designed to work with the OpenAI Agents SDK documentation. Please refer to OpenAI's terms of service for API usage.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选