mcp: best-practices resources + workflow instructions - #6
Merged
Conversation
Adds two LLM-facing affordances to @modernrelay/omnigraph-mcp:
1. Server `instructions` field (~30 lines) set on McpServer init. Most MCP
hosts thread this into the LLM's system context at session start. Leads
with "ALWAYS read schema FIRST" and enumerates the workflow norms an
LLM cannot afford to discover by failure (PascalCase/lowerCamelCase
edge casing, no `mutation {}` wrapper, parameterize everything, the
verify-after-write ritual, the append-only-vs-pointer dedup table,
date format asymmetry, the sync_branch() server-internal vs. tool
distinction, schema_apply destructiveness).
2. Five vendored cookbook references exposed as MCP resources, plus an
index:
omnigraph://best-practices/queries
omnigraph://best-practices/data
omnigraph://best-practices/schema
omnigraph://best-practices/remote-ops
omnigraph://best-practices/search
omnigraph://best-practices/index
Bodies stay out of session context until `resources/read` is called,
so the LLM only pays for what it needs.
Sync mechanics (option B, build-time fetch):
- scripts/sync-cookbook.ts auto-discovers every .md under upstream's
references/ dir via the GitHub contents API, then validates the list
against packages/mcp/cookbook-descriptions.json. The config has
`exposed` (LLM-facing title + description) and `skipped` (one-line
reason) sections. Every upstream file must be in one or the other —
any drift fails the build with a clear remediation message naming the
file and pointing at the config. Curated descriptions stay
hand-written (auto-generated descriptions from filenames are too
vague to guide an LLM's resource selection).
- The sync writes a generated TS module (src/best-practices.gen.ts,
gitignored) that the server imports. The npm tarball ships the
bundled JS with the markdown inlined as string constants — no runtime
network dependency.
- Hooked via prebuild/pretypecheck/pretest in packages/mcp/package.json
so every workflow that touches MCP code keeps the generated module
fresh.
Tarball impact: @modernrelay/omnigraph-mcp goes from 6.6 KB packed
(0.4.0) to ~30 KB packed (0.4.1), unpacked 31 → 103 KB, all of it
inlined cookbook content.
Bumps both packages to 0.4.1 (SDK is unchanged but ships in lockstep
per the major.minor versioning policy). Two new tests cover the
resources/list output and the instructions field.
The drift validation built a union of "known" keys before checking unaccounted upstream files, so a key that appeared in BOTH `exposed` and `skipped` would silently pass the unaccounted check — then `exposed` would win at fetch time and the `skipped` reason became dead config. Add a separate intersection check so contradictory state is reported with its own remediation line.
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
An LLM picking up `@modernrelay/omnigraph-mcp` cold has no idea about workflow norms — call schema first, parameterize queries, edge casing trap, verify writes, append-only retry-safety, etc. The OpenAPI surface doesn't communicate any of this. This PR fixes that with two affordances:
1. Server `instructions` field
~30 lines set on `McpServer` init. MCP hosts thread this into the LLM's system context at session start. Leads with:
Then enumerates the 8 workflow norms an LLM cannot afford to discover by failure: PascalCase/lowerCamelCase edge casing, no `mutation {}` wrapper, parameterize everything, the `commits_list` verify-after-write ritual, append-only-vs-pointer dedup table, branch-then-merge for risky writes, schema_apply destructiveness, date asymmetry, and the `sync_branch()` server-internal vs. tool distinction.
2. Five vendored cookbook references as MCP resources
```
omnigraph://best-practices/queries — before .gq queries (read/change)
omnigraph://best-practices/data — before ingest (mode selection, branch loop)
omnigraph://best-practices/schema — before schema_apply
omnigraph://best-practices/remote-ops — after any 504 or unexpected error
omnigraph://best-practices/search — before nearest/bm25/rrf queries
omnigraph://best-practices/index — what each of the above covers
```
Bodies stay out of session context until `resources/read` is called — the LLM only pays for what it needs.
Sync mechanics (hybrid auto-discover + curated descriptions)
Tarball impact
`@modernrelay/omnigraph-mcp` goes from 6.6 KB packed (0.4.0) to ~30 KB packed (0.4.1); unpacked 31 → 103 KB. All inlined cookbook content. SDK unchanged but ships in lockstep per the major.minor versioning policy.
Test plan
After merge
```bash
git tag -a v0.4.1 -m "Release 0.4.1"
git push --follow-tags
approve the `release` environment in the Actions UI
```
🤖 Generated with Claude Code
Note
Medium Risk
Medium risk because it changes MCP server initialization (adds
instructions) and introduces a build-time GitHub fetch/generation step that can fail builds or drift with upstream content.Overview
The MCP server now provides an LLM-facing
instructionsblock on initialize, emphasizing schema-first workflows and key safety norms for queries, ingest, retries, and schema changes.It also exposes a set of
omnigraph://best-practices/*markdown resources (plus anindex) whose bodies are vendored fromModernRelay/omnigraph-cookbooksat build time via a newsync-cookbookscript, with curated titles/descriptions enforced bycookbook-descriptions.json.Build/test hooks run the sync automatically, the generated module is
.gitignore’d/cleaned, tests assert the new resources/instructions, and package versions bump to0.4.1(including addingtsxas a dev dependency).Reviewed by Cursor Bugbot for commit f9d0ca5. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Adds workflow instructions and ships best-practices docs as MCP resources in
@modernrelay/omnigraph-mcpto guide safe, efficient use (read schema first, verify writes, parameterize, etc.). Content is vendored at build time and fetched on demand; both packages bump to0.4.1.New Features
omnigraph://schemafirst; parameterize queries; verify-after-write withcommits_list; branch→ingest→verify→merge for risky writes; append-only vs pointer retry safety;.gqedge casing and nomutation {}wrapper;schema_applyis main-only and destructive; date formats;nearest/bm25/rrfrequire a trailinglimit;sync_branch()is server-internal text.omnigraph://best-practices/queries,data,schema,remote-ops,search, plusindex. Bodies are returned only onresources/read.Dependencies
packages/mcp/scripts/sync-cookbook.tsauto-discovers upstream markdown, validates againstpackages/mcp/cookbook-descriptions.json(now also fails if a key appears in bothexposedandskipped), and generatessrc/best-practices.gen.ts(gitignored). Wired viaprebuild/pretypecheck/pretest; no runtime network dependency.tsx; version bumps to0.4.1for@modernrelay/omnigraph-mcpand@modernrelay/omnigraph. MCP tarball ~6.6 KB → ~30 KB due to inlined docs.Written for commit f9d0ca5. Summary will update on new commits.