Skip to content

fix(clp-mcp-server): Replace database.name with database.names.clp (fixes #1820).#1821

Merged
junhaoliao merged 1 commit into
y-scope:mainfrom
junhaoliao:mcp-server-db-name
Dec 19, 2025
Merged

fix(clp-mcp-server): Replace database.name with database.names.clp (fixes #1820).#1821
junhaoliao merged 1 commit into
y-scope:mainfrom
junhaoliao:mcp-server-db-name

Conversation

@junhaoliao

@junhaoliao junhaoliao commented Dec 19, 2025

Copy link
Copy Markdown
Member

Description

PR #1606 changed the database configuration interface from database.name (single string) to
database.names (dictionary with ClpDbNameType.CLP and ClpDbNameType.SPIDER keys). The MCP
server was not updated to use this new interface, causing an AttributeError on startup.

This PR updates clp_connector.py to use the new interface.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  1. Built the project:

    task
  2. Configured the MCP server in build/clp-package/etc/clp-config.yaml:

    mcp_server:
      host: localhost
      port: 8000
  3. Started the CLP package:

    cd build/clp-package
    ./sbin/start-clp.sh
  4. Compressed sample logs:

    ./sbin/compress.sh --timestamp=timestamp ~/samples/postgresql.jsonl

    Output:

    2025-12-19T05:44:33.210 INFO [compress] Compression job 1 submitted.
    2025-12-19T05:44:35.214 INFO [compress] Compressed 392.84MB into 9.94MB (39.53x). Speed: 211.48MB/s.
    2025-12-19T05:44:35.715 INFO [compress] Compression finished.
    2025-12-19T05:44:35.715 INFO [compress] Compressed 392.84MB into 9.94MB (39.53x). Speed: 183.57MB/s.
    
  5. Verified the MCP server is alive:

    curl http://localhost:8000/health

    Output:

    OK
    
  6. Initialized an MCP session:

    curl -i -X POST http://localhost:8000/mcp \
      -H "Content-Type: application/json" \
      -H "Accept: application/json, text/event-stream" \
      -d '{
        "jsonrpc": "2.0",
        "id": 1,
        "method": "initialize",
        "params": {
          "protocolVersion": "2024-11-05",
          "capabilities": {},
          "clientInfo": {"name": "test", "version": "1.0"}
        }
      }'

    Output (note the mcp-session-id header):

    HTTP/1.1 200 OK
    ...
    mcp-session-id: 539a40d16a584d40b4c1bf100df7ad0a
    ...
    event: message
    data: {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05",...,"serverInfo":{"name":"clp-mcp-server","version":"2.14.1"}}}
    
  7. Listed available MCP tools:

    curl -X POST http://localhost:8000/mcp \
      -H "Content-Type: application/json" \
      -H "Accept: application/json, text/event-stream" \
      -H "Mcp-Session-Id: 539a40d16a584d40b4c1bf100df7ad0a" \
      -d '{
        "jsonrpc": "2.0",
        "id": 2,
        "method": "tools/list",
        "params": {}
      }'

    Output:

    event: message
    data: {"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"get_instructions",...},{"name":"get_nth_page",...},{"name":"hello_world",...},{"name":"search_by_kql",...},{"name":"search_by_kql_with_timestamp_range",...}]}}
    
  8. Invoked the get_instructions tool (required before other tools):

    curl -X POST http://localhost:8000/mcp \
      -H "Content-Type: application/json" \
      -H "Accept: application/json, text/event-stream" \
      -H "Mcp-Session-Id: 539a40d16a584d40b4c1bf100df7ad0a" \
      -d '{
        "jsonrpc": "2.0",
        "id": 4,
        "method": "tools/call",
        "params": {
          "name": "get_instructions",
          "arguments": {}
        }
      }'

    Output:

    event: message
    data: {"jsonrpc":"2.0","id":4,"result":{"content":[{"type":"text","text":"You are an AI assistant for querying the CLP log database using CLP-KQL (CKQL)..."}],...,"isError":false}}
    
  9. Invoked the search_by_kql tool:

    curl -X POST http://localhost:8000/mcp \
      -H "Content-Type: application/json" \
      -H "Accept: application/json, text/event-stream" \
      -H "Mcp-Session-Id: 539a40d16a584d40b4c1bf100df7ad0a" \
      -d '{
        "jsonrpc": "2.0",
        "id": 5,
        "method": "tools/call",
        "params": {
          "name": "search_by_kql",
          "arguments": {
            "kql_query": "1"
          }
        }
      }'

    Output:

    event: message
    data: {"jsonrpc":"2.0","id":5,"result":{"content":[{"type":"text","text":"{\"items\":[\"timestamp: 2023-03-27T00:31:55.999Z, message: {...}\\n, link: http://localhost:4000/streamFile?...\",...],\"num_total_pages\":4,\"num_total_items\":38,\"num_items_per_page\":10,\"has_next\":true,\"has_previous\":false}"}],...,"isError":false}}
    

    ✅ Observed results are getting returned.

Summary by CodeRabbit

  • Refactor
    • Updated internal database configuration handling to improve code organization and maintainability. This change does not affect user-facing functionality or application behaviour.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A single file in the CLP MCP server connector module is modified to access the MariaDB database name through a named mapping using ClpDbNameType.CLP instead of direct property access, accompanied by a new import addition.

Changes

Cohort / File(s) Change Summary
Database name access refactoring
components/clp-mcp-server/clp_mcp_server/clp_connector.py
Changed database name reference from clp_config.database.name to clp_config.database.names[ClpDbNameType.CLP] and added ClpDbNameType import

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

  • Straightforward property access pattern change in a single file
  • Addition of a new import for the enum type
  • No complex logic or behavioral changes to verify

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main change: replacing database.name with database.names.clp in the MCP server code, and it references the related issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65b3c7c and 55601f6.

📒 Files selected for processing (1)
  • components/clp-mcp-server/clp_mcp_server/clp_connector.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check-generated
🔇 Additional comments (2)
components/clp-mcp-server/clp_mcp_server/clp_connector.py (2)

8-8: LGTM: Import addition is correct.

The import of ClpDbNameType is necessary for accessing the database name through the new configuration interface.


35-35: Fix correctly addresses the AttributeError.

The change properly uses the new database.names[ClpDbNameType.CLP] interface introduced in PR #1606. Verification confirms no other deprecated database.name references remain in the MCP server component, ensuring the fix is complete.


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.

@junhaoliao junhaoliao marked this pull request as ready for review December 19, 2025 05:48
@junhaoliao junhaoliao requested a review from a team as a code owner December 19, 2025 05:48
@junhaoliao junhaoliao merged commit 4158c61 into y-scope:main Dec 19, 2025
24 checks passed
@junhaoliao junhaoliao deleted the mcp-server-db-name branch December 19, 2025 06:51
davidlion pushed a commit to davidlion/clp that referenced this pull request Jan 17, 2026
junhaoliao added a commit to junhaoliao/clp that referenced this pull request May 17, 2026
junhaoliao added a commit to junhaoliao/clp that referenced this pull request May 17, 2026
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