You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a simple example agent that demonstrates how to detect and report which custom features are enabled or disabled in the OpenBB Workspace UI.
3
+
This agent demonstrates how to integrate and use Model Context Protocol (MCP) tools within an OpenBB agent, enabling dynamic tool execution for enhanced functionality.
4
4
5
5
## What it does
6
6
7
7
This agent:
8
-
- Greets users with a friendly hello message
9
-
- Reports the status of custom features (Deep Research and Web Search)
10
-
- Shows whether each feature is enabled (✅) or disabled (❌) based on the UI settings
8
+
- Detects and lists available MCP tools from connected MCP servers
9
+
- Executes MCP tools with proper parameter handling
10
+
- Formats responses clearly separating MCP tool output from AI analysis
11
+
- Supports real-time tool execution through the OpenBB frontend
11
12
12
-
## Features
13
+
## Key Features
13
14
14
-
The agent defines two custom features in its configuration:
15
-
-**Deep Research**: Allows the agent to perform deep research (default: disabled)
16
-
-**Web Search**: Allows the agent to search the web (default: enabled)
15
+
### MCP Tool Integration
16
+
-**Automatic Tool Detection**: Discovers MCP tools from connected servers
17
+
-**Parameter Schema Support**: Validates and passes parameters based on tool schemas
18
+
-**Server Management**: Handles multiple MCP servers with proper server ID mapping
19
+
-**Error Handling**: Graceful fallbacks when tools are unavailable or fail
17
20
18
-
Users can toggle these features on/off in the OpenBB Workspace UI, and the agent will detect and report the current status.
21
+
### Response Formatting
22
+
All responses with MCP tool data are structured as:
23
+
```
24
+
## MCP OUTPUT
25
+
[Raw data from MCP tool execution]
26
+
27
+
## AI OUTPUT
28
+
[AI analysis and interpretation of the tool results]
29
+
```
30
+
31
+
This clear separation helps users distinguish between actual tool data and AI-generated insights.
32
+
33
+
## Supported MCP Tools
34
+
35
+
This example works with any MCP tools, but includes specific support for:
36
+
-**OpenBB Docs Tools**: For querying OpenBB documentation
37
+
-**Data Retrieval Tools**: For fetching structured data
38
+
-**Analysis Tools**: For processing and analyzing information
19
39
20
-
## Getting started
40
+
## How MCP Integration Works
41
+
42
+
1.**Tool Discovery**: Agent detects available MCP tools from connected servers
43
+
2.**Schema Parsing**: Reads tool input schemas to understand required parameters
44
+
3.**Function Definition**: Creates OpenAI function definitions for each tool
45
+
4.**Execution Flow**:
46
+
- User requests action requiring external data
47
+
- Agent calls appropriate MCP tool with parameters
48
+
- Frontend executes tool on MCP server
49
+
- Results returned and formatted for user
50
+
5.**Response Generation**: AI analyzes tool output and provides insights
51
+
52
+
## Getting Started
21
53
22
54
### Prerequisites
23
55
24
-
Ensure you have poetry, a tool for dependency management and packaging in Python, as well as your OpenAI API key.
56
+
- Poetry for dependency management
57
+
- OpenAI API key
58
+
- MCP server with tools configured in OpenBB Terminal Pro
25
59
26
60
### Installation and Running
27
61
28
62
1. Clone this repository to your local machine.
29
63
30
-
2. Set the OpenAI API key as an environment variable in your .bashrc or .zshrc file:
64
+
2. Set the OpenAI API key as an environment variable:
31
65
32
66
```sh
33
67
# in .zshrc or .bashrc
34
68
export OPENAI_API_KEY=<your-api-key>
35
69
```
36
70
37
-
3. Install the necessary dependencies:
71
+
3. Install dependencies:
38
72
39
73
``` sh
40
74
poetry install --no-root
@@ -43,22 +77,65 @@ poetry install --no-root
43
77
4. Start the API server:
44
78
45
79
``` sh
46
-
cd37-vanilla-agent-custom-features
47
-
poetry run uvicorn vanilla_agent_custom_features.main:app --port 7777 --reload
80
+
cd38-vanilla-agent-mcp-tools
81
+
poetry run uvicorn vanilla_agent_mcp_tools.main:app --port 7777 --reload
48
82
```
49
83
50
-
This command runs the FastAPI application, making it accessible on your network.
84
+
### Testing MCP Integration
85
+
86
+
To test MCP tool functionality:
51
87
52
-
### Testing the Agent
88
+
1. Ensure you have MCP tools configured in OpenBB Terminal Pro
89
+
2. Ask the agent: "What MCP tools do you have available?"
90
+
3. Request tool execution: "Use [tool_name] to search for [query]"
91
+
4. Observe the structured output with MCP OUTPUT and AI OUTPUT sections
53
92
54
-
The example agent has a small, basic test suite to ensure it's working correctly. As you develop your agent, you are highly encouraged to expand these tests.
93
+
### Running Tests
55
94
56
-
You can run the tests with:
95
+
The agent includes tests for MCP tool integration:
57
96
58
97
```sh
59
98
pytest tests
60
99
```
61
100
62
-
### Accessing the Documentation
101
+
### Configuration
102
+
103
+
The agent automatically configures MCP tool support through:
104
+
- **Feature Flag**: `"mcp-tools": true`in the agent configuration
105
+
- **Tool Detection**: Automatic discovery from `request.tools`
0 commit comments