Skip to content

Commit d58b18d

Browse files
committed
feat: mcp server can be configured programmatically
1 parent 9798e9e commit d58b18d

10 files changed

Lines changed: 465 additions & 242 deletions

File tree

README.md

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Using the server, you benefit from faster creation of pipelines or indexes and s
2020
- [2.2 Manage Tools](#manage-tools)
2121
- [2.3 Reduce Tool Count](#reduce-tool-count)
2222
- [2.4 Prompts](#prompts)
23+
- [2.5 Providing a Remote MCP Server](#providing-a-remote-mcp-server)
2324
- [3. Use Cases](#use-cases)
2425
- [3.1. Creating Pipelines](#creating-pipelines)
2526
- [3.2. Debugging Pipelines](#debugging-pipelines)
@@ -216,7 +217,6 @@ For example:
216217
"env": {
217218
"DEEPSET_API_KEY":"<DEEPSET_API_KEY>"
218219
}
219-
220220
}
221221
}
222222
}
@@ -320,15 +320,63 @@ All tools exposed through the MCP server have minimal prompts. Any Agent interac
320320

321321
View the **recommended prompt** [here](src/deepset_mcp/prompts/deepset_debugging_agent.md).
322322

323-
This prompt is also exposed as the `deepset_recommended_prompt` on the MCP server.
324-
325323
In Cursor, add the prompt to `.cursorrules`.
326324

327325
In Claude Desktop, create a "Project" and add the prompt as system instructions.
328326

329327
You may find that customizing the prompt for your specific needs yields best results.
330328

331329

330+
### Providing a Remote MCP Server
331+
332+
The `deepset-mcp` package can be configured to run as a remote MCP server, allowing you to provide deepset platform access to multiple users through a centralized service. This is particularly useful for organizations that want to deploy the MCP server as a shared service or integrate it into existing infrastructure.
333+
334+
**Prerequisites**
335+
336+
- Python 3.9 or higher
337+
- `uv` package manager installed
338+
- Knowledge of FastAPI or similar web framework
339+
- OAuth authentication system (recommended)
340+
- SSL/TLS certificate for production deployment
341+
342+
**Key Requirements**
343+
344+
When running as a remote MCP server, you must configure the following:
345+
346+
1. **Transport Protocol**: Use `streamable-http` instead of the default `stdio` transport
347+
2. **Authentication**: Implement OAuth or similar authentication flow to securely handle user credentials
348+
3. **Authorization Headers**: Ensure client requests include proper `Authorization` headers with Bearer tokens
349+
4. **Dynamic Workspace Mode**: Use `workspace_mode='dynamic'` to support multiple users with different workspaces
350+
5. **API Key Management**: Enable `get_api_key_from_auth_header` to extract deepset API keys from request headers
351+
352+
**Implementation Example**
353+
354+
Here's a complete example of how to set up a remote MCP server:
355+
356+
```python
357+
from mcp.server.fastmcp import FastMCP
358+
from deepset_mcp import configure_mcp_server, WorkspaceMode, ALL_DEEPSET_TOOLS, DEEPSET_DOCS_DEFAULT_SHARE_URL
359+
360+
# Create FastMCP instance
361+
mcp = FastMCP("Deepset Remote MCP Server")
362+
363+
# Add authentication middleware
364+
365+
# Configure the deepset MCP server
366+
configure_mcp_server(
367+
mcp_server_instance=mcp,
368+
workspace_mode=WorkspaceMode.DYNAMIC,
369+
tools_to_register=ALL_DEEPSET_TOOLS,
370+
deepset_docs_shareable_prototype_url=DEEPSET_DOCS_DEFAULT_SHARE_URL,
371+
get_api_key_from_authorization_header=True
372+
)
373+
374+
# Run the server
375+
if __name__ == "__main__":
376+
mcp.run(transport="streamable-http")
377+
```
378+
379+
332380
## Use Cases
333381

334382
The primary way to use the deepset MCP server is through an LLM that interacts with the deepset MCP tools in an agentic way.
@@ -374,7 +422,7 @@ If your pipeline is not deployed yet, the Agent can autonomously validate it and
374422

375423
### deepset-mcp
376424

377-
The `deepset-mcp`-command starts the `deepset-mcp` server.
425+
The `deepset-mcp` command starts the Deepset MCP server to interact with the deepset AI platform.
378426

379427
You can run it in your terminal via `uvx deepset-mcp`.
380428

@@ -384,14 +432,16 @@ If you want to run a specific version, you can run:
384432

385433
The following options are available:
386434

387-
| Option | Shorthand | Description |
388-
|------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
389-
| --api-key | -k | The deepset API key to use. Can also be set it via the "DEEPSET_API_KEY" environment variable. |
390-
| --workspace | -w | The deepset workspace to use. Can also be set via the "DEEPSET_WORKSPACE" environment variable. |
391-
| --workspace-mode | -m | If you want to allow an Agent to access multiple workspaces (Options: static, dynamic; default: static) |
392-
| --list-tools | -l | List all available tools (does not start the server). |
393-
| --tools | -t | Pass a space separated list of tool names that you want the server to register. |
394-
| --docs-share-url | -d | Pass a [shared prototype](https://docs.cloud.deepset.ai/docs/share-a-pipeline-prototype) URL to customize which pipeline the Agent uses for documentation search (default: official deepset documentation) |
435+
| Option | Description |
436+
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
437+
| --api-key | The deepset API key to use. Can also be set it via the "DEEPSET_API_KEY" environment variable. |
438+
| --workspace | The deepset workspace to use. Can also be set via the "DEEPSET_WORKSPACE" environment variable. |
439+
| --workspace-mode | If you want to allow an Agent to access multiple workspaces (Options: static, dynamic; default: static) |
440+
| --list-tools | List all available tools (does not start the server). |
441+
| --tools | Pass a space separated list of tool names that you want the server to register. |
442+
| --docs-share-url | Pass a [shared prototype](https://docs.cloud.deepset.ai/docs/share-a-pipeline-prototype) URL to customize which pipeline the Agent uses for documentation search (default: official deepset documentation) |
443+
| --api-key-from-auth-header | Get the deepset API key from the request's authorization header instead of using a static key. |
444+
| --transport | The type of transport to use for running the MCP server (Options: stdio, streamable-http; default: stdio) |
395445

396446

397447
### Tools

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ dependencies = [
4949
"glom",
5050
"rich",
5151
"pyjwt[crypto]",
52+
"typer",
5253
]
5354

5455
[project.urls]
5556
Homepage = "https://deepset.ai"
5657

5758
[project.scripts]
58-
deepset-mcp = "deepset_mcp.main:main"
59+
deepset-mcp = "deepset_mcp.main:app"
5960

6061
[dependency-groups]
6162
dev = [

src/deepset_mcp/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
import importlib.metadata
5+
from deepset_mcp.config import DEEPSET_DOCS_DEFAULT_SHARE_URL
6+
from deepset_mcp.server import configure_mcp_server
7+
from deepset_mcp.tool_models import WorkspaceMode
8+
from deepset_mcp.tool_registry import ALL_DEEPSET_TOOLS
69

7-
try:
8-
__version__ = importlib.metadata.version(__name__)
9-
except importlib.metadata.PackageNotFoundError:
10-
__version__ = "0.0.0" # Fallback for development mode
10+
__all__ = ["configure_mcp_server", "WorkspaceMode", "ALL_DEEPSET_TOOLS", "DEEPSET_DOCS_DEFAULT_SHARE_URL"]

src/deepset_mcp/config.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44

55
"""This module contains static configuration for the deepset MCP server."""
66

7-
from deepset_mcp import __version__
7+
import importlib.metadata
8+
9+
try:
10+
__version__ = importlib.metadata.version("deepset-mcp")
11+
except importlib.metadata.PackageNotFoundError:
12+
__version__ = "0.0.0" # Fallback for development mode
13+
14+
PACKAGE_VERSION = __version__
815

916
# We need this mapping to which environment variables integrations are mapped to
1017
# The mapping is maintained in the pipeline operator:
@@ -29,5 +36,6 @@
2936
}
3037

3138
DEEPSET_DOCS_DEFAULT_SHARE_URL = "https://cloud.deepset.ai/shared_prototypes?share_token=prototype_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3ODM0MjE0OTguNTk5LCJhdWQiOiJleHRlcm5hbCB1c2VyIiwiaXNzIjoiZEMiLCJ3b3Jrc3BhY2VfaWQiOiI4YzI0ZjExMi1iMjljLTQ5MWMtOTkzOS1hZTkxMDRhNTQyMWMiLCJ3b3Jrc3BhY2VfbmFtZSI6ImRjLWRvY3MtY29udGVudCIsIm9yZ2FuaXphdGlvbl9pZCI6ImNhOWYxNGQ0LWMyYzktNDYwZC04ZDI2LWY4Y2IwYWNhMDI0ZiIsInNoYXJlX2lkIjoiY2Y3MTA3ODAtOThmNi00MzlmLThiNzYtMmMwNDkyODNiMDZhIiwibG9naW5fcmVxdWlyZWQiOmZhbHNlfQ.5j6DCNRQ1_KB8lhIJqHyw2hBIleEW1_Y_UBuH6MTYY0"
39+
DOCS_SEARCH_TOOL_NAME = "search_docs"
3240

33-
DEFAULT_CLIENT_HEADER = {"headers": {"User-Agent": f"deepset-mcp/{__version__}"}}
41+
DEFAULT_CLIENT_HEADER = {"headers": {"user-agent": f"deepset-mcp/{__version__}"}}

0 commit comments

Comments
 (0)