Skip to content

feat: surface PCM save-schema reference to the LLM - #14

Open
mpicciolli wants to merge 4 commits into
mainfrom
doc/database-convention
Open

feat: surface PCM save-schema reference to the LLM#14
mpicciolli wants to merge 4 commits into
mainfrom
doc/database-convention

Conversation

@mpicciolli

Copy link
Copy Markdown
Collaborator

Summary

The DATABASE.md save-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 writing pcm_query_save queries. This surfaces that reference to the client through two complementary channels.

What changed

  • pcm://docs/database resource — serves the full DATABASE.md on demand for clients that support resource browsing/attachment (src/resources/, wired in src/index.ts).
  • Condensed cheatsheet in the pcm_query_save descriptionSCHEMA_CHEATSHEET in query-save.ts keeps 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.md stays the single source of truth — its contents are inlined into the bundle at build time via the esbuild text loader (tsup.config.ts), mirrored by a small Vite plugin for vitest (vitest.config.ts). Nothing extra ships alongside dist/.
  • DocsREADME.md (new Resources section) and AGENTS.md (conventions + layout) updated, including a rule to keep the cheatsheet in sync whenever DATABASE.md changes.

Testing

  • npm run build ✓ (reference inlined into dist/index.js; no separate file shipped)
  • npm test — 89/89 ✓
  • stdio smoke test: resources/read pcm://docs/database returns the full doc; pcm_query_save description carries the cheatsheet

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 2, 2026 11:34

Copilot AI 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.

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/database MCP resource that serves the bundled DATABASE.md reference.
  • Embeds a condensed schema cheatsheet into the pcm_query_save tool description, pointing to the full resource.
  • Updates build/test tooling to inline .md imports 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 thread src/resources/index.ts
Comment on lines +4 to +6
export function registerRessources(server: McpServer): void {
registerDatabaseResource(server);
}
Comment thread src/index.ts
Comment on lines 5 to +18
@@ -14,6 +15,7 @@ const server = new McpServer({
});

registerTools(server);
registerRessources(server);
Comment thread AGENTS.md
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/
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