Skip to content

feat: Add MCP server configuration support to CLI#149

Open
DhruvGarg111 wants to merge 3 commits into
Bessouat40:mainfrom
DhruvGarg111:feature/issue-79-mcp-cli-clean
Open

feat: Add MCP server configuration support to CLI#149
DhruvGarg111 wants to merge 3 commits into
Bessouat40:mainfrom
DhruvGarg111:feature/issue-79-mcp-cli-clean

Conversation

@DhruvGarg111

Copy link
Copy Markdown

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)

  • Updated AgenticRAGConfig.mcp_config type from List[StdioServerParameters] to Dict[str, Dict[str, Any]] to match the langchain-mcp-adapters 0.2.1 API
  • Removed unused StdioServerParameters import
  • Updated example file to use correct dictionary format with named servers
  • MultiServerMCPClient expects a dict mapping server names to Connection configs, not a list

2. Add CLI Support (commit 6839f3d)

  • Added headless mode support via RAGLIGHT_MCP_URLS environment variable (comma-separated list of SSE endpoints)
  • Added interactive prompt for MCP server configuration in Step 4
  • Generates proper dictionary format with named servers (mcp_server_0, mcp_server_1, etc.)
  • All servers default to sse transport type
  • Passes mcp_config to AgenticRAGConfig initialization

Usage

Headless Mode

export RAGLIGHT_MCP_URLS="http://127.0.0.1:8001/sse,http://127.0.0.1:8002/sse"
raglight agentic-chat

Interactive Mode

Run raglight agentic-chat and respond to the new Step 4 prompt to configure MCP servers interactively.

Testing

  • All Python files compile without syntax errors
  • Format matches langchain-mcp-adapters 0.2.1 documented API
  • Example file updated to demonstrate correct usage

Notes

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

- 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
@DhruvGarg111

Copy link
Copy Markdown
Author

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.

Comment thread src/raglight/cli/main.py
llm_base_url = cfg.llm_api_base
llm_model = cfg.llm_model
k = cfg.k
mcp_urls_env = cfg.mcp_urls

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServerConfig doesn't have an attribute mcp_urls, you need to add it

@Bessouat40

Copy link
Copy Markdown
Owner

And thanks for the fix concerning the data format langchain-mcp-adapters API is waiting for !

@DhruvGarg111

DhruvGarg111 commented Apr 9, 2026

Copy link
Copy Markdown
Author

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

Comment thread README.md
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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MCP for CLI usage

2 participants