Skip to content

Add MCP server#15

Open
MartinDevi wants to merge 10 commits into
mainfrom
mdevillers/add-mcp-server
Open

Add MCP server#15
MartinDevi wants to merge 10 commits into
mainfrom
mdevillers/add-mcp-server

Conversation

@MartinDevi

Copy link
Copy Markdown

Summary

  • Adds a FastMCP server exposing the document index over the Model Context Protocol
  • Tools: search, ingest, open_source, navigate_source, read_source, grep_source
  • Supports both stdio (default) and HTTP transport modes
  • Wires up MCP config via .mcp.json.jinja and documents usage in the README

Test plan

  • Run make mcp and verify the server starts in stdio mode
  • Run make mcp-http and verify the server starts on localhost:8000
  • Ingest a document via the ingest tool and confirm chunks are indexed
  • Run search and confirm results are returned
  • Use open_source / navigate_source / read_source / grep_source on a returned hit

🤖 Generated with Claude Code

@MartinDevi
MartinDevi requested a review from afoucret July 8, 2026 15:01
MartinDevi and others added 3 commits July 8, 2026 17:04
… server

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@afoucret
afoucret requested a review from haralambievk July 8, 2026 16:47

@haralambievk haralambievk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

love the direction, but as this is a public repo let's coordinate with product when and how to put this out

@MartinDevi

Copy link
Copy Markdown
Author

MCP Search Tools — Test Results

Tested all five MCP tools against two ingested documents:

  • ACTIVISIONBLIZZARD_2015_10K.pdf — 182-page SEC 10-K filing (244 chunks)
  • A 4-page French maritime safety guide from mer.gouv.fr (4 chunks), later deleted

search — hybrid BM25 + vector retrieval

Ran queries in both English and French. Results were correctly ranked with meaningful scores and pointed to the right sections of the right documents:

  • "executive compensation CEO salary" → top hit: Part III / Item 11 Executive Compensation section (score 6.2), followed by the Stock-Based Compensation note (score 4.6)
  • "équipements de sécurité balisage lumineux" → top 3 hits all from the French maritime doc (scores 14.2, 13.8, 13.4), zero bleed from the 10-K

Cross-document isolation worked correctly — semantically distant queries did not surface results from the wrong document.

grep_source — lexical phrase/term search within a document

  • "Call of Duty" in the 10-K → 3 relevant chunks found across pages 5, 6, and 8
  • "gilet de sauvetage" in the maritime doc → correct chunk found on page 3

navigate_source — sequential chunk navigation

Navigated forward 2 chunks from the Executive Compensation section (page 89): correctly returned Part IV (page 90) then the Signatures page (page 91) in reading order.

open_source — context window expansion

Expanded window=2 around the Executive Compensation chunk: returned the 2 preceding chunks (Items 9A/9B, internal controls — pages 87–88) and 2 following chunks (Part IV, Signatures — pages 90–91). Order and content correct.

read_source — offset-range reads

  • Full document read of the 4-page maritime doc (top_k=4): returned all 4 chunks in order
  • Range read of the 10-K with start_offset=334969, end_offset=340000: returned the 2 chunks that fall within that range (pages 89–90), nothing outside it

delete + verification

Deleted the maritime doc by source_id. Verified:

  • grep_source on the deleted source → Source not found error
  • search with a French maritime query → zero results from the deleted doc; only low-score 10-K results remain

All tools working correctly.

MartinDevi and others added 4 commits July 9, 2026 15:49
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Port search strategy guidance from the arxiv-search skill into the MCP
server tool docstrings, where agents can read it when tools are loaded.

- search: clarify entry-point role, query scoping via BM25/doc_title,
  query refinement on poor hits, and cross-document connection pattern
- open_source: add follow-up options after expanding a chunk
- navigate_source: clarify sequential reading use case, steer toward
  grep_source/scoped search for non-adjacent targets
- grep_source: add grep-vs-search heuristic with generic examples

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>


@mcp.tool()
async def search(query: str, top_k: int = 5) -> list[dict]:

@alexandretamborrino alexandretamborrino Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess we also want to add exclude_ids as a parameter of the Search tool

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.

3 participants