Skip to content

Add opt-in documentation discovery (llms.txt) to the MCP server - #217

Merged
rohitkumarbhagat merged 8 commits into
datacommonsorg:mainfrom
rohitkumarbhagat:llms_txt
Sep 15, 2026
Merged

rohitkumarbhagat merged 8 commits into
datacommonsorg:mainfrom
rohitkumarbhagat:llms_txt

Conversation

@rohitkumarbhagat

@rohitkumarbhagat rohitkumarbhagat commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Add optional, client-controlled guidance for discovering Data Commons documentation through llms.txt.

The guidance directs clients to read the index for API, library, schema, dataset coverage, concept, and integration questions, then follow only relevant documentation links. Statistical queries continue to use the existing MCP tools and skills.

Configuration

Documentation guidance is disabled by default, including autopush.

  • DC_ENABLE_DOCUMENTATION sets the server default and configures stdio deployments.
  • HTTP clients can override it using X-DC-Enable-Documentation: true or false.
  • An absent header inherits the server default.
  • Values are case-insensitive and trimmed; invalid values are rejected.
  • Clients should reconnect after changing their preference.

Disabling the feature omits the guidance; it does not restrict access to public documentation.

Implementation

  • Keep server.md unchanged.
  • Store the guidance in doc_instructions_extension.md, overridable through DC_INSTRUCTIONS_DIR.
  • Prepare base-only and base-plus-documentation instructions in DCApp.
  • Select instructions per client without modifying shared server state.
  • Remove the documentation resource and server-side fetching. Clients fetch the index and linked pages directly.

The direct-link approach avoids resource registration and filtering because clients already need URL-reading capability to access the linked documentation.

FastMCP remains pinned to 3.4.2. The isolated private session-options dependency is documented and covered by initialization tests.

Validation

  • All 50 MCP tests pass.
  • HTTP tests cover both server defaults, client overrides, and concurrent-client isolation.
  • Tests cover custom instructions, header validation, and headerless fallback.
  • Lint, formatting, and diff checks pass.
  • A temporary CLI experiment validated direct-index discovery and documentation-based example generation without general web search. The final refactored code has not yet been rerun through that CLI.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces the option to expose the official Data Commons documentation resource, controlled by the new DC_ENABLE_DOCUMENTATION_RESOURCE setting. When enabled, the server registers a documentation index resource and appends a routing hint to the server instructions. The feedback recommends moving the requests import from the module level to inside the registration function to defer loading and keep server startup fast when the feature is disabled.

Comment thread packages/datacommons-mcp/datacommons_mcp/server.py Outdated
Comment thread packages/datacommons-mcp/datacommons_mcp/server.py Outdated
Comment thread packages/datacommons-mcp/datacommons_mcp/middleware.py Outdated
Comment thread packages/datacommons-mcp/datacommons_mcp/middleware.py Outdated
Comment thread packages/datacommons-mcp/datacommons_mcp/server.py Outdated
Comment thread packages/datacommons-mcp/datacommons_mcp/middleware.py

@keyurva keyurva left a comment

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.

Thanks Rohit! Consider whether we need the server flag. LGTM otherwise.

Comment thread packages/datacommons-mcp/datacommons_mcp/data_models/settings.py Outdated
@rohitkumarbhagat

Copy link
Copy Markdown
Contributor Author

Thanks Rohit! Consider whether we need the server flag. LGTM otherwise.

Thanks Keyur. Removed server side flag.

@rohitkumarbhagat
rohitkumarbhagat merged commit ebbab12 into datacommonsorg:main Sep 15, 2026
13 of 14 checks passed
@rohitkumarbhagat
rohitkumarbhagat deleted the llms_txt branch September 15, 2026 02:43

This branch was successfully deployed

No deployments
evals-and-secrets 655da805 Deployed Sep 15, 2026 by rohitkumarbhagat via agent-evals #497
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