Skip to content

RSPEED-2402: Enable MCP tool use on rlsapi /v1/infer endpoint#1113

Merged
tisnik merged 1 commit intolightspeed-core:mainfrom
major:rlsapi-v1-mcp-tools
Feb 8, 2026
Merged

RSPEED-2402: Enable MCP tool use on rlsapi /v1/infer endpoint#1113
tisnik merged 1 commit intolightspeed-core:mainfrom
major:rlsapi-v1-mcp-tools

Conversation

@major
Copy link
Contributor

@major major commented Feb 6, 2026

Description

RSPEED-2402

Allow the rlsapi v1 (/v1/infer) endpoint to use MCP servers transparently.
The client sends a plain question and gets a plain text answer, but behind the
scenes the LLM can call MCP tools (e.g., a RAG knowledge base) to enrich its
response.

The query v2 endpoint already supports MCP. The rlsapi v1 endpoint uses the
same underlying responses.create() API — it just never passed the tools
parameter. This change closes that gap by reusing get_mcp_tools() from
query v2.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: Claude Opus 4
  • Generated by: Claude Opus 4

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  1. Configure mcp_servers in lightspeed-stack.yaml:
    mcp_servers:
      - name: "rag-knowledge-base"
        url: "http://rag-mcp-server:9000/sse"
  2. Send a POST to /v1/infer with a question that benefits from tool use
  3. Verify the response contains information enriched by the MCP tool
  4. Send a POST to /v1/infer with no mcp_servers configured — verify
    identical behavior to before this change (regression test)

Summary by CodeRabbit

Release Notes

  • New Features
    • MCP tool support is now integrated into the RLS API v1. Tools from configured MCP servers are automatically available during response generation.
    • The system seamlessly handles tool passthrough to the language model, enabling richer interactions with available tools from your server configuration.

- Import get_mcp_tools from query_v2 endpoint module
- Add tools parameter to retrieve_simple_response()
- Pass MCP tool definitions to responses.create()
- Build MCP tools from configuration in infer_endpoint()
- Add unit tests for tools passthrough and default behavior
- Add integration tests for MCP tools and no-MCP regression

Signed-off-by: Major Hayden <major@redhat.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

Walkthrough

This pull request adds MCP (Model Context Protocol) tool support to the RLS API v1 retrieve flow. The retrieve_simple_response function is updated to accept an optional tools parameter, which is passed to the Llama Stack client. The infer_endpoint function is modified to compute MCP tools from configuration and forward them through the retrieve flow.

Changes

Cohort / File(s) Summary
Core API Endpoint
src/app/endpoints/rlsapi_v1.py
Updated retrieve_simple_response signature to accept optional tools parameter and wire tools into Llama Stack client calls. Modified infer_endpoint to compute MCP tools via get_mcp_tools and pass them to retrieve_simple_response.
Integration Tests
tests/integration/endpoints/test_rlsapi_v1_integration.py
Added two integration tests: one verifying empty tools list passthrough when no MCP servers are configured, and another verifying MCP tool definitions are forwarded to the LLM responses endpoint.
Unit Tests
tests/unit/app/endpoints/test_rlsapi_v1.py
Added helper function _setup_responses_mock_with_capture and three unit tests covering tool parameter passthrough in retrieve_simple_response, default empty tools behavior, and infer_endpoint calling get_mcp_tools.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant infer_endpoint
    participant get_mcp_tools
    participant retrieve_simple_response
    participant LlamaStackClient as Llama Stack Client

    Client->>infer_endpoint: POST /infer<br/>(question, instructions)
    infer_endpoint->>get_mcp_tools: Call with<br/>configuration.mcp_servers
    get_mcp_tools-->>infer_endpoint: Return tools list
    infer_endpoint->>retrieve_simple_response: Call with<br/>(question, instructions, tools)
    retrieve_simple_response->>LlamaStackClient: client.responses.create<br/>(..., tools=tools)
    LlamaStackClient-->>retrieve_simple_response: Response with<br/>generated text
    retrieve_simple_response-->>infer_endpoint: Return response text
    infer_endpoint-->>Client: Return response
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Suggested Labels

ok-to-test

Suggested Reviewers

  • tisnik
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: enabling MCP tool use on the rlsapi /v1/infer endpoint, which aligns perfectly with the primary objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM, nice work

@tisnik tisnik merged commit 13d2bcc into lightspeed-core:main Feb 8, 2026
19 of 21 checks passed
@major major deleted the rlsapi-v1-mcp-tools branch February 9, 2026 15:09
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.

2 participants