Skip to content

Commit 8a0f450

Browse files
authored
[Feature] openbb-mcp-server: Refactor for FastMCP V3 (#7380)
* add developer and user interface skills to baseline openbb-mcp server * pylint * tests * refactor for fastmcp v3 * pylint * fix some v3 syntax and add tools for list and read resources * more deprecated imports * too-many-lines * add name slug and use description from below the title instead of short sentence * add VSCodeSkillsProvider to imports and vendor skills providers map * replace custom prompt tools with PromptsAsTools transform * use ResourcesAsTools transforms instead of manual list/read functions * replace ToolRegistry with CategoryIndex * update readme and skill files * use in docstring.. * clean docstring * codespell * more pyproject.toml * fix merge conflict --------- Co-authored-by: deeleeramone <>
1 parent a984001 commit 8a0f450

28 files changed

Lines changed: 5083 additions & 1168 deletions

openbb_platform/extensions/mcp_server/README.md

Lines changed: 83 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
This extension enables LLM agents to interact with OpenBB Platform's REST API endpoints through the MCP protocol.
44

5-
The server provides discovery tools that allow agents to explore different options and dynamically adjust their active toolset.
6-
This prevents agents from being overwhelmed with too many tools while allowing them to discover and activate only the tools they need for specific tasks.
5+
The server provides discovery tools that allow agents to explore available categories and dynamically activate only the tools they need.
6+
This keeps the initial tool list small — preventing token bloat — while still giving agents access to the full platform on demand.
77

8-
Using dynamic tool discovery has one major drawback, it makes the server a single-user server.
9-
The tool updates are global, so if one user updates a tool, it will be updated for all users.
10-
11-
If you plan to serve multiple users, you should disable tool discovery,
12-
and instead use the `allowed_tool_categories` and `default_tool_categories` settings to control the tools that are available to the users.
8+
Tool visibility changes are **per-session**: each connected client has its own active toolset.
9+
Multiple agents can connect simultaneously and independently activate different tools without interfering with each other.
1310

1411
## Installation & Usage
1512

@@ -90,7 +87,7 @@ The server can be configured through multiple methods, with settings applied in
9087
1. **Command Line Arguments**: Highest priority, overriding all other methods.
9188
2. **Environment Variables**: Each setting can be controlled by an environment variable, which will override the configuration file.
9289
3. **Configuration File**: A JSON file at `~/.openbb_platform/mcp_settings.json` provides the base configuration.
93-
- If the cnofiguration file does not exist, one will be populated with the defaults.
90+
- If the configuration file does not exist, one will be populated with the defaults.
9491

9592
> **Note:** For some data providers you need to set your API key in the `~/.openbb_platform/user_settings.json` file.
9693
@@ -221,21 +218,24 @@ All settings in the `MCPSettings` model can be configured via the `mcp_settings.
221218
| `name` | `OPENBB_MCP_NAME` | string | `"OpenBB MCP"` | Server name. |
222219
| `description` | `OPENBB_MCP_DESCRIPTION` | string | | Server description. |
223220
| `version` | `OPENBB_MCP_VERSION` | string | `None` | Server version. |
221+
| `instructions` | `OPENBB_MCP_INSTRUCTIONS` | string | `None` | Server instructions sent during the MCP `initialize` handshake. Auto-populated from system prompt if not set. |
224222
| `default_tool_categories` | `OPENBB_MCP_DEFAULT_TOOL_CATEGORIES` | list[string] | `["all"]` | Default active tool categories on startup. |
225223
| `allowed_tool_categories` | `OPENBB_MCP_ALLOWED_TOOL_CATEGORIES` | list[string] | `None` | Restricts available tool categories to this list. |
226-
| `enable_tool_discovery` | `OPENBB_MCP_ENABLE_TOOL_DISCOVERY` | boolean | `True` | Enable tool discovery. |
224+
| `enable_tool_discovery` | `OPENBB_MCP_ENABLE_TOOL_DISCOVERY` | boolean | `True` | Enable per-session tool discovery (admin tools for browse/activate/deactivate). |
225+
| `list_page_size` | `OPENBB_MCP_LIST_PAGE_SIZE` | integer | `None` | Max items per page in MCP list responses. `None` disables pagination. |
227226
| `describe_responses` | `OPENBB_MCP_DESCRIBE_RESPONSES` | boolean | `False` | Include response types in tool descriptions. |
228227
| `system_prompt_file` | `OPENBB_MCP_SYSTEM_PROMPT_FILE` | string | `None` | Path to a text file for the system prompt. |
229228
| `server_prompts_file` | `OPENBB_MCP_SERVER_PROMPTS_FILE` | string | `None` | Path to a JSON file with a list of server prompt definitions. |
229+
| `default_skills_dir` | `OPENBB_MCP_DEFAULT_SKILLS_DIR` | string | *(bundled skills dir)* | Path to a directory of bundled skill files. Set to `null` to disable. |
230+
| `skills_reload` | `OPENBB_MCP_SKILLS_RELOAD` | boolean | `False` | Reload skill files on every read (useful during development). |
231+
| `skills_providers` | `OPENBB_MCP_SKILLS_PROVIDERS` | list[string] | `None` | Vendor skill provider short-names to load (e.g. `["claude", "cursor"]`). |
230232
| `cache_expiration_seconds` | `OPENBB_MCP_CACHE_EXPIRATION_SECONDS` | float | `None` | Cache expiration time in seconds. `0` to disable. |
231233
| `on_duplicate_tools` | `OPENBB_MCP_ON_DUPLICATE_TOOLS` | string | `None` | Behavior for duplicate tools (`warn`, `error`, `replace`, `ignore`). |
232234
| `on_duplicate_resources` | `OPENBB_MCP_ON_DUPLICATE_RESOURCES` | string | `None` | Behavior for duplicate resources. |
233235
| `on_duplicate_prompts` | `OPENBB_MCP_ON_DUPLICATE_PROMPTS` | string | `None` | Behavior for duplicate prompts. |
234236
| `resource_prefix_format` | `OPENBB_MCP_RESOURCE_PREFIX_FORMAT` | string | `None` | Format for resource URI prefixes (`protocol` or `path`). |
235237
| `mask_error_details` | `OPENBB_MCP_MASK_ERROR_DETAILS` | boolean | `None` | Mask error details from user functions. |
236238
| `dependencies` | `OPENBB_MCP_DEPENDENCIES` | list[string] | `None` | List of dependencies to install. |
237-
| `include_tags` | `OPENBB_MCP_INCLUDE_TAGS` | set[string] | `None` | Only expose components with these tags. |
238-
| `exclude_tags` | `OPENBB_MCP_EXCLUDE_TAGS` | set[string] | `None` | Exclude components with these tags. |
239239
| `module_exclusion_map` | `OPENBB_MCP_MODULE_EXCLUSION_MAP` | dict[str, str] | `None` | Map API tags to Python module names for exclusion. |
240240
| `uvicorn_config` | `OPENBB_MCP_UVICORN_CONFIG` | dict | `{"host": "127.0.0.1", "port": "8001"}` | Configuration for the Uvicorn server. |
241241
| `httpx_client_kwargs` | `OPENBB_MCP_HTTPX_CLIENT_KWARGS` | dict | `{}` | Configuration for the async httpx client. |
@@ -269,36 +269,43 @@ Each category contains subcategories that group related functionality (e.g., `eq
269269

270270
An additional set of tools are tagged as "admin", or "prompt".
271271

272-
- available_categories
272+
- **available_categories**: List all tool categories with subcategory names and tool counts.
273+
274+
- **available_tools**: List tools in a specific category (and optional subcategory).
275+
- `category`: Category of tools to list.
276+
- `subcategory`: Optional subcategory. Use `general` for tools directly under the category.
277+
- Inactive tools still show a short description so they remain discoverable.
273278

274-
- available_tools: List all tools by category.
275-
- `category`: Category of tool to list.
276-
- `subcategory`: Optional subcategory. Use 'general' for tools directly under the category.
279+
- **activate_tools**: Activate one or more tools by name for this session.
280+
- `tool_names`: List of tool names to activate.
277281

278-
- activate_tools: Activate a tool for use.
279-
- `tool_names`: Names of tools to activate. Comma-separated string for multiple.
282+
- **deactivate_tools**: Deactivate one or more tools by name for this session.
283+
- `tool_names`: List of tool names to deactivate.
280284

281-
- deactivate_tools: Deactivate a tool after use.
282-
- `tool_names`: Names of tools to deactivate. Comma-separated string for multiple.
285+
- **activate_category**: Activate all tools in a category (or subcategory) at once.
286+
- `category`: Category name.
287+
- `subcategory`: Optional subcategory to narrow the activation.
283288

284-
- list_prompts: Lists all available prompts in the server.
289+
- **list_prompts**: Lists all available prompts in the server.
285290

286-
- execute_prompt: Execute a prompt with arguments, if any.
291+
- **execute_prompt**: Execute a prompt with arguments, if any.
287292
- `prompt_name`: Name of the prompt to execute.
288293
- `arguments`: Dictionary of argument:value for the prompt.
289294

290295
## Tool Discovery
291296

292-
When `enable_tool_discovery` is enabled (default), the server provides discovery tools that allow agents to:
297+
When `enable_tool_discovery` is enabled (default), the server registers a small set of admin tools that let agents progressively discover and activate what they need:
293298

294-
- Discover available tool categories and subcategories
295-
- See tool counts and descriptions before activating
296-
- Enable/disable specific tools dynamically during a session
297-
- Start with minimal tools and progressively add more as needed
299+
1. **Browse**`available_categories` returns the category tree with tool counts.
300+
2. **Inspect**`available_tools` lists every tool in a category with its active/inactive state and a short description.
301+
3. **Activate**`activate_tools` or `activate_category` enables specific tools (or an entire category) for the current session.
302+
4. **Deactivate**`deactivate_tools` removes tools when they are no longer needed.
298303

299-
To take full advantage of minimal startup tools, you should set the `--default-categories` argument to `admin`. This will enable only the discovery tools at startup.
304+
All visibility changes are **per-session** — each client maintains its own active toolset, so the server is safe for multi-user deployments.
300305

301-
For multi-client deployments or scenarios where you want a fixed toolset, disable tool discovery with `--no-tool-discovery`.
306+
To take full advantage of minimal startup tools, set `--default-categories admin` so only the discovery tools are active on connect.
307+
308+
For scenarios where you want a completely fixed toolset (no discovery overhead), disable it with `--no-tool-discovery` and control the available tools via `allowed_tool_categories` and `default_tool_categories`.
302309

303310
## System Prompt
304311

@@ -309,6 +316,54 @@ The system prompt is made available as a resource, `resource://system_prompt`, a
309316

310317
Clients will not automatically use the system prompt, instruct them to use it as part of their onboarding and orientation.
311318

319+
## Skills
320+
321+
The server ships with a set of bundled **skill guides** — Markdown documents that teach an agent how to perform complex multi-step tasks with the OpenBB Platform.
322+
Skills are exposed as MCP resources and are discoverable via `list_resources()`.
323+
324+
Each skill is available at a URI of the form `skill://<name>/SKILL.md`.
325+
326+
### Bundled Skills
327+
328+
| Skill | URI | Description |
329+
|---|---|---|
330+
| `develop_extension` | `skill://develop_extension/SKILL.md` | Step-by-step guide for building an OpenBB Platform extension. |
331+
| `build_workspace_app` | `skill://build_workspace_app/SKILL.md` | Guide for building and running OpenBB Workspace applications. |
332+
| `configure_mcp_server` | `skill://configure_mcp_server/SKILL.md` | Reference for configuring and customising the OpenBB MCP Server. |
333+
| `work_with_server` | `skill://work_with_server/SKILL.md` | Practical guide for working with the OpenBB MCP Server as an agent. |
334+
335+
When any skills are loaded and no `system_prompt_file` is configured, the server automatically adds a brief default system prompt that nudges the agent to discover available skills.
336+
337+
### Skill Settings
338+
339+
| Setting | Description |
340+
|---|---|
341+
| `default_skills_dir` | Path to the bundled skills directory. Set to `null` or an empty string to disable loading the built-in skills. |
342+
| `skills_reload` | Set to `true` to reload skill files from disk on every read — useful when authoring or iterating on skill content. |
343+
| `skills_providers` | A list of vendor skill provider short-names. Supported values: `claude`, `cursor`, `vscode`, `copilot`, `codex`, `gemini`, `goose`, `opencode`. |
344+
345+
**Example — disable bundled skills:**
346+
347+
```json
348+
{
349+
"default_skills_dir": null
350+
}
351+
```
352+
353+
**Example — load vendor skill providers:**
354+
355+
```json
356+
{
357+
"skills_providers": ["claude", "cursor"]
358+
}
359+
```
360+
361+
**Example — enable skill reload during development:**
362+
363+
```env
364+
OPENBB_MCP_SKILLS_RELOAD=true
365+
```
366+
312367
## Server Prompts
313368

314369
A system prompt file can be added on initialization, or defined in the configuration file, or as an environment variable.

0 commit comments

Comments
 (0)