feat: surface PCM save-schema reference to the LLM - #14
Open
mpicciolli wants to merge 4 commits into
Open
Conversation
…TABASE.md as a resource
…ndensed cheatsheet to query-save tool
There was a problem hiding this comment.
Pull request overview
This PR makes the PCM save-schema reference available to MCP clients at runtime, so LLMs can write more accurate pcm_query_save SQL (tables/columns/joins) without guessing.
Changes:
- Adds a
pcm://docs/databaseMCP resource that serves the bundledDATABASE.mdreference. - Embeds a condensed schema cheatsheet into the
pcm_query_savetool description, pointing to the full resource. - Updates build/test tooling to inline
.mdimports as strings (tsup loader + matching vitest plugin), plus docs updates.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Adds a Vite plugin so .md imports resolve as text during vitest runs. |
| tsup.config.ts | Configures esbuild loader to inline .md files as strings in the bundle. |
| src/tools/query-save.ts | Adds schema cheatsheet into the tool description and links to the resource URI. |
| src/resources/index.ts | Adds resource registration entrypoint (currently with a naming typo). |
| src/resources/database-reference.ts | Registers pcm://docs/database resource serving the inlined reference content. |
| src/reference.ts | Centralizes the inlined DATABASE.md content and canonical resource URI constant. |
| src/md.d.ts | Declares *.md modules as string for TypeScript. |
| src/index.ts | Wires resource registration into server startup (currently using the same naming typo). |
| README.md | Documents the new pcm://docs/database resource. |
| DATABASE.md | Adds the save-schema reference document that is surfaced to clients. |
| AGENTS.md | Updates repo layout/conventions, but currently lists the wrong resource filename. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4
to
+6
| export function registerRessources(server: McpServer): void { | ||
| registerDatabaseResource(server); | ||
| } |
Comment on lines
5
to
+18
| @@ -14,6 +15,7 @@ const server = new McpServer({ | |||
| }); | |||
|
|
|||
| registerTools(server); | |||
| registerRessources(server); | |||
Comment on lines
+32
to
35
| reference.ts # loads DATABASE.md (DATABASE_REFERENCE) for the query tool + resource | ||
| resources/ | ||
| database.ts # pcm://docs/database resource (serves DATABASE.md) | ||
| schemas/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
DATABASE.mdsave-schema conventions were only visible to Claude Code when working on the repo — the LLM using the MCP server had no access to them at runtime, so it had to guess table/column naming and joins when writingpcm_query_savequeries. This surfaces that reference to the client through two complementary channels.What changed
pcm://docs/databaseresource — serves the fullDATABASE.mdon demand for clients that support resource browsing/attachment (src/resources/, wired insrc/index.ts).pcm_query_savedescription —SCHEMA_CHEATSHEETinquery-save.tskeeps just the essentials (table/column prefixes, FK pattern with key exceptions, display columns) in every-turn context, and points to the resource for full detail. Description stays ~1.4 KB instead of embedding the full ~3.4 KB doc.DATABASE.mdstays the single source of truth — its contents are inlined into the bundle at build time via the esbuildtextloader (tsup.config.ts), mirrored by a small Vite plugin for vitest (vitest.config.ts). Nothing extra ships alongsidedist/.README.md(new Resources section) andAGENTS.md(conventions + layout) updated, including a rule to keep the cheatsheet in sync wheneverDATABASE.mdchanges.Testing
npm run build✓ (reference inlined intodist/index.js; no separate file shipped)npm test— 89/89 ✓resources/read pcm://docs/databasereturns the full doc;pcm_query_savedescription carries the cheatsheet🤖 Generated with Claude Code