feat: Add MCP server configuration support to CLI#149
Conversation
- Change AgenticRAGConfig.mcp_config type from List[StdioServerParameters] to Dict[str, Dict[str, Any]] to match langchain-mcp-adapters 0.2.1 API - Remove unused StdioServerParameters import - Update example file to use correct dict format with named servers - MultiServerMCPClient expects dict mapping server names to Connection configs, not a list of parameters Related to issue Bessouat40#79
- Add headless mode support via RAGLIGHT_MCP_URLS environment variable (comma-separated list of SSE endpoints) - Add interactive prompt for MCP server configuration in Step 4 - Generate proper dict format with named servers (mcp_server_0, mcp_server_1, etc.) - All servers default to 'sse' transport type - Pass mcp_config to AgenticRAGConfig initialization Implements issue Bessouat40#79
|
Hi! Just to clarify my implementation approach: I noticed that the existing MCP example in the repository was using a list format that doesn't match the langchain-mcp-adapters API (version 0.2.1 requires a dictionary mapping server names to Connection configs). So I fixed both the type annotation and the example file while adding the CLI support. If you prefer a different approach or if I misunderstood the requirements, please let me know and I will be happy to revise the implementation. |
| llm_base_url = cfg.llm_api_base | ||
| llm_model = cfg.llm_model | ||
| k = cfg.k | ||
| mcp_urls_env = cfg.mcp_urls |
There was a problem hiding this comment.
ServerConfig doesn't have an attribute mcp_urls, you need to add it
|
And thanks for the fix concerning the data format langchain-mcp-adapters API is waiting for ! |
|
Thanks for the review! I've added mcp_urls to ServerConfig, updated the documentation and examples to use the correct dictionary format with the required transport key and added RAGLIGHT_MCP_URLS to the headless environment variables |
| raglight agentic-chat | ||
| ``` | ||
|
|
||
| If you want to configure an MCP server (e.g., to give your agent access to external tools), you can run the wizard or set `RAGLIGHT_MCP_URLS="http://127.0.0.1:8001/sse"` before launching the CLI to bypass the prompt and run in headless mode. |
There was a problem hiding this comment.
Maybe user need to init RAGLIGHT_MCP_URLS value with http://127.0.0.1:8001 instead of http://127.0.0.1:8001/sse ?
There was a problem hiding this comment.
For this PR, i m using transport: "sse" with MultiServerMCPClient. In this setup, the client needs the actual SSE endpoint—not just the base server URL.
I tested it locally with a FastMCP SSE server: the base URL (http://127.0.0.1:8123) returns a 404, but http://127.0.0.1:8123/sse works and correctly discovers the tools.
So RAGLIGHT_MCP_URLS should include /sse when using SSE transport (unless the server exposes SSE at the root).
Summary
This PR implements MCP (Model Context Protocol) server configuration support for the CLI, as requested in #79.
Changes
1. Fix MCP Config Type (commit 54097b7)
AgenticRAGConfig.mcp_configtype fromList[StdioServerParameters]toDict[str, Dict[str, Any]]to match thelangchain-mcp-adapters0.2.1 APIStdioServerParametersimportMultiServerMCPClientexpects a dict mapping server names to Connection configs, not a list2. Add CLI Support (commit 6839f3d)
RAGLIGHT_MCP_URLSenvironment variable (comma-separated list of SSE endpoints)mcp_server_0,mcp_server_1, etc.)ssetransport typemcp_configtoAgenticRAGConfiginitializationUsage
Headless Mode
Interactive Mode
Run
raglight agentic-chatand respond to the new Step 4 prompt to configure MCP servers interactively.Testing
langchain-mcp-adapters0.2.1 documented APINotes
I noticed the existing MCP example and type annotation were using a format incompatible with
langchain-mcp-adapters>=0.1.0. This PR fixes both the framework configuration and adds CLI support in one go.If the approach here doesn't match your vision for the feature, please let me know and I'm happy to adjust!
Closes #79