Skip to content

Commit 2befe6b

Browse files
committed
Merge branch 'main' into refactor
2 parents 1240af1 + 2d31ed6 commit 2befe6b

4 files changed

Lines changed: 18 additions & 37 deletions

File tree

README.md

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,11 @@ You can also then run commands by first activating `poetry shell` which should a
1818
After installing poetry, install the poetry shell plugin with `poetry self add poetry-plugin-shell` and you should be good to go.
1919

2020

21-
### 2. Creating the vector database
22-
Create the 'data' folder by running
23-
```bash
24-
mkdir src/data
25-
```
26-
Check the README.md in the `src/scripts` directory for more information on how to populate the vector database.
27-
28-
Run the vector database population script to create the vector database collections:
29-
```bash
30-
python src/database/populate_vector_db.py
31-
```
21+
### 2. Setting up MCP tools
3222

33-
#### Automatic Database Updates
34-
Opey II can automatically check for OBP data changes on startup and update the vector database when changes are detected. To enable this feature, set in your `.env`:
35-
36-
```env
37-
UPDATE_DATABASE_ON_STARTUP="true"
38-
UPDATE_DATABASE_ENDPOINT_TYPE="all" # Options: "static", "dynamic", "all"
39-
```
23+
`cp mcp_servers.example.json mcp_servers.json`
4024

41-
When enabled, the system will:
42-
- Fetch current OBP glossary and endpoint data on startup
43-
- Compare with previously imported data using SHA-256 hashes
44-
- Rebuild the database only if changes are detected
45-
- Store hashes for future comparisons
25+
As a minimum, Opey should be connected to [OBP-MCP](https://github.com/OpenBankProject/OBP-MCP), or it won't know anything about the Open Bank Project except for what you put in the [system prompt](#5-changing-the-system-prompt). Instructions for setting up OBP-MCP as an internal, consent-based MCP server that works with OBP-Portal etc. can be found in [Appendix 1](https://github.com/OpenBankProject/OBP-MCP/blob/main/README.md#appendix-1---opey-setup) of the OBP-MCP readme.
4626

4727
### 3. Setting up the environment
4828
First you will need to rename the `.env.example` file to `.env` and change several parameters. You have options on which LLM provider you decide to use for the backend agent system.

mcp_servers.example.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"name": "obp-mcp",
55
"url": "http://localhost:9100/mcp",
66
"transport": "streamable_http",
7-
"requires_auth": true,
8-
"_comment": "OBP-MCP server with bearer token auth (token from frontend OAuth flow)"
7+
"forward_bearer_token": true,
8+
"_comment": "OBP-MCP server - forwards the user's OAuth bearer token via Authorization header"
99
},
1010
{
1111
"name": "local-tools",
1212
"url": "http://localhost:8001/mcp",
1313
"transport": "streamable_http",
14-
"requires_auth": false,
14+
"forward_bearer_token": false,
1515
"_comment": "Local MCP server without authentication"
1616
},
1717
{

src/agent/components/tools/mcp_integration.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class MCPServerConfig:
4040
url: Optional[str] = None
4141
headers: Dict[str, str] = field(default_factory=dict)
4242

43-
# Whether this server requires bearer token authentication
44-
# If True, the bearer token from the session will be added to requests
45-
requires_auth: bool = False
43+
# Whether to forward the user's bearer token to this server
44+
# If True, the bearer token from the session will be added as an Authorization header
45+
forward_bearer_token: bool = False
4646

4747
# stdio transport
4848
command: Optional[str] = None
@@ -64,7 +64,7 @@ def __init__(self, servers: List[MCPServerConfig], bearer_token: Optional[str] =
6464
Args:
6565
servers: List of server configurations
6666
bearer_token: Optional bearer token for authenticated requests.
67-
If provided, adds Authorization header to servers with requires_auth=True.
67+
If provided, adds Authorization header to servers with forward_bearer_token=True.
6868
"""
6969
self.servers = servers
7070
self.bearer_token = bearer_token
@@ -134,11 +134,11 @@ def _build_client_config(self) -> Dict[str, Any]:
134134

135135
# Build headers, injecting bearer token if needed
136136
headers = dict(server.headers) # Copy to avoid mutating config
137-
if server.requires_auth and self.bearer_token:
137+
if server.forward_bearer_token and self.bearer_token:
138138
headers["Authorization"] = f"Bearer {self.bearer_token}"
139139
logger.debug(f"Injecting bearer token for MCP server '{server.name}'")
140-
elif server.requires_auth and not self.bearer_token:
141-
logger.warning(f"MCP server '{server.name}' requires auth but no bearer token provided")
140+
elif server.forward_bearer_token and not self.bearer_token:
141+
logger.warning(f"MCP server '{server.name}' has forward_bearer_token=true but no bearer token provided")
142142

143143
if headers:
144144
config["headers"] = headers

src/service/mcp_tools_cache.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def _parse_mcp_config() -> List[MCPServerConfig]:
9292
url=raw.get("url"),
9393
transport=raw.get("transport", "streamable_http"),
9494
headers=raw.get("headers", {}),
95-
requires_auth=raw.get("requires_auth", False),
95+
# Support both new "forward_bearer_token" and legacy "requires_auth"
96+
forward_bearer_token=raw.get("forward_bearer_token", raw.get("requires_auth", False)),
9697
command=raw.get("command"),
9798
args=raw.get("args", []),
9899
env=raw.get("env"),
@@ -124,8 +125,8 @@ async def initialize_mcp_tools() -> List[BaseTool]:
124125
return []
125126

126127
# Split servers by auth requirement
127-
no_auth_servers = [s for s in _server_configs if not s.requires_auth]
128-
auth_servers = [s.name for s in _server_configs if s.requires_auth]
128+
no_auth_servers = [s for s in _server_configs if not s.forward_bearer_token]
129+
auth_servers = [s.name for s in _server_configs if s.forward_bearer_token]
129130

130131
if auth_servers:
131132
logger.info(f"Servers requiring auth (loaded per-request): {auth_servers}")
@@ -178,7 +179,7 @@ def get_server_configs() -> List[MCPServerConfig]:
178179
def get_auth_required_servers() -> List[str]:
179180
"""Get list of server names that require bearer token authentication."""
180181
configs = get_server_configs()
181-
return [s.name for s in configs if s.requires_auth]
182+
return [s.name for s in configs if s.forward_bearer_token]
182183

183184

184185
async def get_mcp_tools_with_auth(bearer_token: Optional[str] = None) -> List[BaseTool]:

0 commit comments

Comments
 (0)