Skip to content

Multiple backend changes to make use of the new mcp tools and improve… - #440

Open
miss-o-soup wants to merge 8 commits into
datacommonsorg:mainfrom
miss-o-soup:backend-mcp-updates
Open

Multiple backend changes to make use of the new mcp tools and improve…#440
miss-o-soup wants to merge 8 commits into
datacommonsorg:mainfrom
miss-o-soup:backend-mcp-updates

Conversation

@miss-o-soup

@miss-o-soup miss-o-soup commented Aug 10, 2026

Copy link
Copy Markdown

Backend, MCP Integration, Skills & Data Access
Updated Fallbacks for Data Facets (src/server/steps/observations.ts):

  • Dataset Source: Changed fallback from 'Data Commons' to an empty string '' (meta?.source || data.importName || ''). When neither metadata nor API import names exist, it now cleanly defaults to empty instead of injecting generic filler.
  • Units: Changed default fallback for un-unitized variables from 'Dimensionless' to 'Unit not specified' (data.unit || 'Unit not specified').

Integration of Updated Data Commons MCP Tools & Remote Playbooks:

  • Metadata Resolution (observations.ts): Concurrently query get_variable_metadata via MCP during time-series fetching to map exact dataset provenance names (isPartOf, source, url).
  • Remote MCP Skill Playbooks (src/server/clients/mcp.ts & src/server/steps/data_discovery.ts): Implemented readMcpResource via JSON-RPC resources/read to dynamically fetch and inject remote playbooks (skill://data-commons-researcher/SKILL.md) into Gemini's system instruction.

Data Discovery Skill Rules & Lead-in Prompts (data_discovery.md):

  • Rule 0 (Strict Verbatim Copying): Mandated copying variable DCIDs and names verbatim from MCP search outputs, prohibiting inferred/invented demographic labels and enforcing places_with_data verification.
  • Rule 0.1 (Lead-in Intro Rules): Constrained the table card introduction to a 1-sentence framing description (12–22 words) explicitly attributing data to "Data Commons", following John Saito tone guidelines, and utilizing dynamic variation patterns (Patterns A–D).

Data Comparison Skill Prompt (data_comparison.md):

  • Updated comparative insights schema instructions to produce clean, standalone plain-text comparative sentences across places.

BEFORE - The true facet information was missing defaulting to say Data Commons
image

AFTER - Now the true facet info from the metadata mcp tool is being used and displayed
image

… text in the cards

Updated Fallbacks for Data Facets (src/server/steps/observations.ts):
Dataset Source: Changed fallback from 'Data Commons' to an empty string '' (meta?.source || data.importName || ''). When neither metadata nor API import names exist, it now cleanly defaults to empty instead of injecting generic filler.
Units: Changed default fallback for un-unitized variables from 'Dimensionless' to 'Unit not specified' (data.unit || 'Unit not specified').
Integration of Updated Data Commons MCP Tools & Remote Playbooks:
Metadata Resolution (observations.ts): Concurrently query get_variable_metadata via MCP during time-series fetching to map exact dataset provenance names (isPartOf, source, url).
Remote MCP Skill Playbooks (src/server/clients/mcp.ts & src/server/steps/data_discovery.ts): Implemented readMcpResource via JSON-RPC resources/read to dynamically fetch and inject remote playbooks (skill://data-commons-researcher/SKILL.md) into Gemini's system instruction.
Data Discovery Skill Rules & Lead-in Prompts (data_discovery.md):
Rule 0 (Strict Verbatim Copying): Mandated copying variable DCIDs and names verbatim from MCP search outputs, prohibiting inferred/invented demographic labels and enforcing places_with_data verification.
Rule 0.1 (Lead-in Intro Rules): Constrained the table card introduction to a 1-sentence framing description (12–22 words) explicitly attributing data to "Data Commons", following John Saito tone guidelines, and utilizing dynamic variation patterns (Patterns A–D).
Data Comparison Skill Prompt (data_comparison.md):
Updated comparative insights schema instructions to produce clean, standalone plain-text comparative sentences across places.

@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 MCP skill playbook fetching and caching, refines LLM prompt instructions and schemas across several markdown files, and integrates concurrent metadata retrieval from MCP in fetchTimeSeries to enrich observation facets. The review feedback highlights critical improvements: caching negative results in fetchMcpSkillPlaybook to avoid repeated timeout delays, wrapping metadata parsing in a try-catch block to prevent parsing errors from breaking successful observation fetches, and correcting minor typographical errors in the query analyzer prompt.

Comment thread dataweaver/apps/web/src/server/clients/mcp.ts
Comment thread dataweaver/apps/web/src/server/steps/observations.ts
Comment thread dataweaver/apps/web/src/server/config/skills/parse_query.md Outdated
…ke these descriptions and fallbacks more flexible in cases of incomplete parts (or in the case of dates, duplicate dates, to prevent 2020-2020, etc).
…nting an abort of shared in-flight fetches) and omit fallback text for unspecified units (the latter so that a lengthy indicator that there are no units doesn't take up a large amount of space in the facet description).
@nick-nlb
nick-nlb marked this pull request as ready for review August 18, 2026 01:24
@nick-nlb
nick-nlb requested a review from beets as a code owner August 18, 2026 01:24
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