# How to Use the OpenBB MCP Server Extension for AI Agent Integration

> Integrate AI agents with financial data using the OpenBB MCP server extension. Expose REST endpoints as callable tools for LLM agents via the Model Context Protocol. Query financial data programmatically.

- Repository: [OpenBB/OpenBB](https://github.com/OpenBB-finance/OpenBB)
- Tags: how-to-guide
- Published: 2026-03-05

---

**The OpenBB MCP server extension exposes every OpenBB REST endpoint as a callable tool for LLM agents via the Model Context Protocol (MCP), allowing AI systems to query financial data programmatically through a FastMCP interface.**

The OpenBB MCP server extension bridges the OpenBB financial data platform with large language model (LLM) agents by implementing the Model Context Protocol. This extension, available in the [OpenBB-finance/OpenBB](https://github.com/OpenBB-finance/OpenBB) repository, transforms REST endpoints into schema-compatible tools that agents can discover and invoke autonomously.

## Architecture of the OpenBB MCP Server Extension

The extension centers on four core components that convert OpenBB’s FastAPI routes into LLM-accessible tools.

### Core Service Components

**`MCPService`** acts as a singleton that orchestrates the server lifecycle. Located in [[`openbb_platform/extensions/mcp_server/openbb_mcp_server/service/mcp_service.py`](https://github.com/OpenBB-finance/OpenBB/blob/main/openbb_platform/extensions/mcp_server/openbb_mcp_server/service/mcp_service.py)](https://github.com/OpenBB-finance/OpenBB/blob/develop/openbb_platform/extensions/mcp_server/openbb_mcp_server/service/mcp_service.py), this service loads configurations from `~/.openbb_platform/mcp_settings.json`, merges CLI and environment overrides, and instantiates the FastMCP server. It resolves settings using a strict priority: CLI arguments → environment variables → configuration file → defaults.

**`MCPSettings`** defines the server-wide configuration schema. Found in [[`openbb_platform/extensions/mcp_server/openbb_mcp_server/models/settings.py`](https://github.com/OpenBB-finance/OpenBB/blob/main/openbb_platform/extensions/mcp_server/openbb_mcp_server/models/settings.py)](https://github.com/OpenBB-finance/OpenBB/blob/develop/openbb_platform/extensions/mcp_server/openbb_mcp_server/models/settings.py), this Pydantic model specifies host, port, tool-category filters, authentication, and caching policies. It provides helper methods `get_fastmcp_kwargs()` and `get_http_run_kwargs()` that translate configuration objects into FastMCP constructor arguments.

**`MCPConfigModel`** validates per-endpoint metadata. Implemented in [[`openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py`](https://github.com/OpenBB-finance/OpenBB/blob/main/openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py)](https://github.com/OpenBB-finance/OpenBB/blob/develop/openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py), this schema identifies which OpenBB endpoints to expose, their MCP tool types, allowed HTTP methods, and prompt templates.

**FastMCP Core** is the underlying library that registers FastAPI routes as LLM tools. The extension integrates this via `MCPSettings` helpers and exposes a Uvicorn server (default `127.0.0.1:8001`) that handles HTTP transport, caching, and request validation.

## Configuring the MCP Server Extension

Configuration persists in `~/.openbb_platform/mcp_settings.json`. You can override any setting via environment variables (prefixed with `OPENBB_MCP_`) or CLI flags. For example, setting `OPENBB_MCP_API_PREFIX=/mcp` changes the base path for tool endpoints.

The `MCPService.load_with_overrides()` method implements the merge logic. When called without arguments, it loads the JSON file; when passed keyword arguments like `port=8002` or `host="0.0.0.0"`, those take precedence over file-based settings.

## Starting the OpenBB MCP Server

You can launch the server using the entry point defined in [`pyproject.toml`](https://github.com/OpenBB-finance/OpenBB/blob/main/pyproject.toml) or programmatically via Python.

### Method 1: Command Line Entry Point

```bash

# Uses the console script defined in pyproject.toml

openbb-mcp

# Or via module execution

python -m openbb_mcp_server.run

```

### Method 2: Python Script with Custom Overrides

```python

# launch_mcp.py

from openbb_mcp_server.service.mcp_service import MCPService
from fastmcp import FastMCP

# Load service and apply runtime overrides

service = MCPService()
service.load_with_overrides(port=8002, host="0.0.0.0")

# Extract configuration for FastMCP and HTTP server

fastmcp_kwargs = service.mcp_settings.get_fastmcp_kwargs()
http_kwargs = service.mcp_settings.get_http_run_kwargs()

# Initialize and run the server

app = FastMCP(**fastmcp_kwargs)
app.run_http_async(**http_kwargs)  # Blocks until server stops

```

Run the script to start a Uvicorn instance on all interfaces at port `8002`, pulling base settings from the JSON configuration file and applying your Python overrides.

## Integrating AI Agents with the MCP Server

Once running, the server exposes a tool catalogue at `/mcp/tools` that any agent framework can consume. Each entry contains the tool name, JSON schema parameters, and description.

### LangChain Integration Example

```python

# llm_agent.py

import requests
from langchain.tools import StructuredTool
from langchain.chat_models import ChatOpenAI
from langchain.agents import initialize_agent, AgentType

# 1️⃣ Fetch the tool catalogue from the MCP server

catalogue = requests.get("http://localhost:8002/mcp/tools").json()

# 2️⃣ Convert each MCP tool into a LangChain StructuredTool

def make_tool(entry):
    def _run(**kwargs):
        resp = requests.post(
            f"http://localhost:8002/mcp/{entry['name']}",
            json=kwargs,
            timeout=30,
        )
        return resp.json()
    return StructuredTool.from_function(
        func=_run,
        name=entry["name"],
        description=entry.get("description", ""),
        args_schema=entry.get("parameters", {})
    )

tools = [make_tool(t) for t in catalogue]

# 3️⃣ Build an LLM-driven agent

llm = ChatOpenAI(model_name="gpt-4")
agent = initialize_agent(
    tools,
    llm,
    agent=AgentType.OPENAI_FUNCTIONS,
    verbose=True,
)

# 4️⃣ Execute a query—the agent selects and calls OpenBB tools automatically

answer = agent.run("Give me the latest price for AAPL and a short earnings summary.")
print(answer)

```

The agent receives the user prompt, selects the appropriate tool from the MCP catalogue, sends a JSON payload to `/mcp/{tool_name}`, and returns the structured OpenBB response.

## Summary

- The **OpenBB MCP server extension** converts REST endpoints into LLM tools using the Model Context Protocol.
- **`MCPService`** manages configuration loading from `~/.openbb_platform/mcp_settings.json` with override priority for CLI and environment variables.
- **`MCPSettings`** and **`MCPConfigModel`** provide Pydantic validation for server options and per-route metadata.
- Start the server via the `openbb-mcp` CLI command or programmatically using `MCPService.load_with_overrides()` and `FastMCP.run_http_async()`.
- Agents consume the `/mcp/tools` endpoint to discover capabilities and invoke tools via HTTP POST to `/mcp/{tool_name}`.

## Frequently Asked Questions

### What is the Model Context Protocol (MCP) in OpenBB?

The Model Context Protocol is a standardized interface that allows LLM agents to discover and invoke external tools. In OpenBB, MCP wraps the existing REST API so that AI agents can query financial data, screen stocks, and retrieve economic indicators through structured function calls rather than raw HTTP requests.

### How does the MCP server differ from the standard OpenBB REST API?

The standard REST API requires clients to know exact endpoint paths and construct manual HTTP requests. The **OpenBB MCP server extension** abstracts this by exposing endpoints as named tools with JSON schemas, enabling LLMs to understand available functions and their parameters autonomously. The MCP layer handles caching, tool discovery, and request validation that the base REST API does not provide natively.

### Which AI agent frameworks support the OpenBB MCP server?

Any framework capable of consuming OpenAPI-compatible tool schemas can integrate with the OpenBB MCP server. The examples above demonstrate **LangChain** using `StructuredTool`, but LlamaIndex, AutoGen, and custom agents can similarly fetch the catalogue from `/mcp/tools` and map entries to their respective tool abstractions.

### Where is the MCP configuration file stored and what format does it use?

The configuration file resides at `~/.openbb_platform/mcp_settings.json` and uses JSON format. It stores server-wide settings including host, port, API prefix, and filtering options. The `MCPService` class reads this file on initialization, applying overrides from environment variables (prefixed with `OPENBB_MCP_`) or Python keyword arguments passed to `load_with_overrides()`.