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
Copy file name to clipboardExpand all lines: docs/ARCHITECTURE.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,7 @@ This section describes the major functional components that make up LCore. Each
108
108
-**Lifecycle Management**:
109
109
-**Startup**: Load configuration, initialize Llama Stack client, load MCP server configuration and register all defined servers with Llama Stack to build the tools list, establish database connections
110
110
-**Shutdown**: Clean up A2A storage resources (database connections and other resources are cleaned up automatically by Python's context managers)
111
-
-**Router Registration**: Mount all endpoint routers (query, conversation, model info, auth, metrics, A2A, feedback, admin, mcp_auth)
111
+
-**Router Registration**: Mount all endpoint routers (query, conversation, model info, auth, metrics, A2A, feedback, admin, mcp_auth, mcp_servers)
112
112
113
113
**Note:** All configured MCP servers must be running and accessible at startup time for LCore to initialize successfully.
114
114
@@ -207,6 +207,9 @@ The system defines 30+ actions that can be authorized. Examples (see `docs/auth.
@@ -325,7 +328,7 @@ MCP servers are remote HTTP services that expose tools/capabilities to LLMs (e.g
325
328
326
329
**How It Works:**
327
330
328
-
1.**Configuration:** MCP servers are defined in the config file with name, URL, and authorization headers
331
+
1.**Configuration:** MCP servers are defined in the config file with name, URL, and authorization headers. Servers can also be registered dynamically at runtime via `POST /v1/mcp-servers`.
329
332
2.**Registration at Startup:** LCore tells Llama Stack about each MCP server by calling `toolgroups.register()` - this makes the MCP server's tools available in Llama Stack's tool registry
330
333
3.**Query Processing:** When processing a query, LCore determines which tools to make available to the LLM and finalizes authorization headers (e.g., merging client-provided tokens with configured headers)
331
334
4.**Tool Execution:** When the LLM calls a tool, Llama Stack routes the request to the appropriate MCP server URL with the finalized authorization headers
@@ -489,6 +492,11 @@ This section documents the REST API endpoints exposed by LCore for client intera
489
492
- Returns MCP servers that accept client-provided authentication tokens
490
493
- Includes header names that need to be provided via MCP-HEADERS
491
494
495
+
**MCP Server Management:**
496
+
-`POST /v1/mcp-servers` - Register a new MCP server at runtime
497
+
-`GET /v1/mcp-servers` - List all registered MCP servers (static and dynamic)
498
+
-`DELETE /v1/mcp-servers/{name}` - Unregister a dynamically registered MCP server
Copy file name to clipboardExpand all lines: docs/config.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,7 @@ Global service configuration.
175
175
| llama_stack | | This section contains Llama Stack configuration. Lightspeed Core Stack service can call Llama Stack in library mode or in server mode. |
176
176
| user_data_collection | | This section contains configuration for subsystem that collects user data(transcription history and feedbacks). |
177
177
| database | | Configuration for database to store conversation IDs and other runtime data |
178
-
| mcp_servers | array | MCP (Model Context Protocol) servers provide tools and capabilities to the AI agents. These are configured in this section. Only MCP servers defined in the lightspeed-stack.yaml configuration are available to the agents. Tools configured in the llama-stack run.yaml are not accessible to lightspeed-core agents. |
178
+
| mcp_servers | array | MCP (Model Context Protocol) servers provide tools and capabilities to the AI agents. These are configured in this section. Servers can also be registered dynamically at runtime via the `POST /v1/mcp-servers` API endpoint. Only MCP servers defined in lightspeed-stack.yaml or registered via the API are available to the agents. Tools configured in the llama-stack run.yaml are not accessible to lightspeed-core agents. |
| authorization | | Lightspeed Core Stack implements a modular authentication and authorization system with multiple authentication methods. Authorization is configurable through role-based access control. Authentication is handled through selectable modules configured via the module field in the authentication configuration. |
181
181
| customization | | It is possible to customize Lightspeed Core Stack via this section. System prompt can be customized and also different parts of the service can be replaced by custom Python modules. |
Copy file name to clipboardExpand all lines: docs/getting_started.md
+77-2Lines changed: 77 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,7 +240,7 @@ mcp_servers:
240
240
url: "http://localhost:3002"
241
241
```
242
242
243
-
**Important**: Only MCP servers defined inthe `lightspeed-stack.yaml`configuration are available to the AI agents. Tools configured in the llama-stack `run.yaml` are not accessible to LCS agents.
243
+
**Important**: MCP servers defined in`lightspeed-stack.yaml`or registered dynamically via the API (see [Dynamic MCP Server Management](#dynamic-mcp-server-management-via-api)) are available to the AI agents. Tools configured in the llama-stack `run.yaml` are not accessible to LCS agents.
244
244
245
245
#### Step 3: Pass authentication or metadata via MCP headers (optional)
246
246
@@ -255,4 +255,79 @@ curl -X POST "http://localhost:8080/v1/query" \
255
255
```
256
256
257
257
#### Step 4: Verify connectivity
258
-
After starting the MCP servers and updating `lightspeed-stack.yaml`, test by sending a prompt to the AI agent. LCS evaluates the prompt against available tools’ metadata, selects the appropriate tool, calls the corresponding MCP server, and uses the result to generate more accurate agent response.
258
+
After starting the MCP servers and updating `lightspeed-stack.yaml`, test by sending a prompt to the AI agent. LCS evaluates the prompt against available tools' metadata, selects the appropriate tool, calls the corresponding MCP server, and uses the result to generate more accurate agent response.
259
+
260
+
### Dynamic MCP Server Management via API
261
+
262
+
In addition to static configuration in `lightspeed-stack.yaml`, MCP servers can be registered, listed, and removed at runtime through the REST API. This is useful for development, testing, or scenarios where MCP servers are provisioned dynamically.
263
+
264
+
#### Register an MCP server
265
+
266
+
```bash
267
+
curl -X POST "http://localhost:8080/v1/mcp-servers" \
268
+
-H "Content-Type: application/json" \
269
+
-d '{
270
+
"name": "my-dynamic-tools",
271
+
"url": "http://localhost:9000/mcp",
272
+
"provider_id": "model-context-protocol"
273
+
}'
274
+
```
275
+
276
+
Response (201 Created):
277
+
```json
278
+
{
279
+
"name": "my-dynamic-tools",
280
+
"url": "http://localhost:9000/mcp",
281
+
"provider_id": "model-context-protocol",
282
+
"message": "MCP server 'my-dynamic-tools' registered successfully"
283
+
}
284
+
```
285
+
286
+
Optional fields in the request body:
287
+
- `authorization_headers` (object): Headers to send to the MCP server (e.g., `{"Authorization": "Bearer token123"}`).
288
+
- `headers` (array): List of HTTP header names to forward from incoming requests to this MCP server.
289
+
- `timeout` (integer): Request timeout in seconds.
290
+
291
+
#### List all MCP servers
292
+
293
+
```bash
294
+
curl "http://localhost:8080/v1/mcp-servers"
295
+
```
296
+
297
+
Response (200 OK):
298
+
```json
299
+
{
300
+
"servers": [
301
+
{
302
+
"name": "filesystem-tools",
303
+
"url": "http://localhost:3000",
304
+
"provider_id": "model-context-protocol",
305
+
"source": "config"
306
+
},
307
+
{
308
+
"name": "my-dynamic-tools",
309
+
"url": "http://localhost:9000/mcp",
310
+
"provider_id": "model-context-protocol",
311
+
"source": "api"
312
+
}
313
+
]
314
+
}
315
+
```
316
+
317
+
Each server has a `source` field indicating how it was registered: `"config"` for servers defined in `lightspeed-stack.yaml`, or `"api"` for servers registered via the REST API.
"message": "MCP server 'my-dynamic-tools' unregistered successfully"
330
+
}
331
+
```
332
+
333
+
**Note:** Only dynamically registered servers (source `"api"`) can be deleted via the API. Attempting to delete a statically configured server returns 403 Forbidden. Dynamically registered servers do not persist across service restarts.
0 commit comments