dograh/api/services
Leoy 5762095edf
feat(mcp): add search_docs tool over docs corpus (closes #295) (#316)
* feat(mcp): add search_docs tool over Mintlify docs corpus

Closes #295. The docs at https://docs.dograh.com promise "Search the
Dograh docs for how to configure a TURN server" as an MCP example
prompt, but no search_docs tool exists in the MCP server — agents can
list workspace resources but cannot search the documentation.

This adds a dependency-free, in-process keyword search over the
`docs/` tree shipped into the API image (`COPY ./docs ./docs`):

- New `api/mcp_server/tools/docs_search.py` — async `search_docs(query,
  limit=10)` with weighted scoring (path > title > body), a 25-result
  hard cap, snippet extraction around the first term hit, and graceful
  empty-list degradation when docs aren't on disk. `DOGRAH_DOCS_PATH`
  env var overrides location discovery for non-Docker layouts.

- Registered in `api/mcp_server/server.py` alongside the other tools,
  keeping the existing list-alphabetical convention.

- `api/tests/test_mcp_docs_search.py` — 18 unit tests covering the
  pure helpers (tokenizer, frontmatter stripping, title extraction,
  scoring weights, URL building) and end-to-end ranking, limit
  clamping, empty-corpus degradation, and input-validation errors.
  Mocks `authenticate_mcp_request` to avoid the DB dependency,
  mirroring `test_mcp_save_workflow.py`.

Implementation notes:
- The docs corpus is ~100 files / ~140k LoC, so a per-call scan runs
  well under 50 ms; avoiding a vector index / embedding backend keeps
  the tool zero-dependency and works for fully offline self-hosted
  deployments.
- Authentication is required for consistency with the other MCP tools
  (and to route through the existing rate-limit middleware), even
  though docs are not org-scoped data.
- Title/path matches deliberately outweigh body matches so a page
  whose subject IS the query term outranks one that merely mentions
  it incidentally.

* feat: improve docs search

---------

Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
2026-05-20 18:20:35 +05:30
..
auth feat: add agent skills to review PR (#320) 2026-05-19 17:02:26 +05:30
campaign feat: add Tuner Integration to Dograh (#311) 2026-05-20 14:37:33 +05:30
configuration feat: add Tuner Integration to Dograh (#311) 2026-05-20 14:37:33 +05:30
filesystem chore: bump pipecat version and fix tests (#263) 2026-05-04 21:35:37 +05:30
gen_ai feat: refactor node spec and add mcp tools (#244) 2026-04-21 07:56:16 +05:30
gender Initial Commit 🚀 🚀 2025-09-09 14:37:32 +05:30
integrations feat: add Tuner Integration to Dograh (#311) 2026-05-20 14:37:33 +05:30
pipecat feat: add Tuner Integration to Dograh (#311) 2026-05-20 14:37:33 +05:30
pricing feat: add openai realtime models (#298) 2026-05-16 18:05:23 +05:30
reports fix: number pool initialization in multi telephony setup 2026-05-08 14:48:53 +05:30
smart_turn feat: add headless mode, redesign floating widget, refactor lifecycle callbacks (#268) 2026-05-07 12:23:41 +05:30
telephony feat: add Review AGENTS.md Skill 2026-05-20 16:20:07 +05:30
worker_sync feat: add worker sync events 2026-04-04 14:26:47 +05:30
workflow feat(mcp): add search_docs tool over docs corpus (closes #295) (#316) 2026-05-20 18:20:35 +05:30
mps_service_key_client.py feat: refactor node spec and add mcp tools (#244) 2026-04-21 07:56:16 +05:30
posthog_client.py feat: add posthog signup and signin events, enable backend posthog events for oss version (#249) 2026-04-24 12:02:52 +05:30
quota_service.py feat: enable FORCE_TURN_RELAY to diagnose turn connectivity for local deployment setups (#272) 2026-05-11 17:13:01 +05:30
storage.py chore: bump pipecat version and fix tests (#263) 2026-05-04 21:35:37 +05:30