Repository navigation
MCP: a real system prompt, house rules and a tool call log - #202
Merged
Merged
Conversation
What assistants are told when they connect is now built per connection
(gcm/mcp/instructions.py):
- instructions.md: how to use the tools, GTNH units and tiers, and what
models got wrong in use. Much of a base is kept stocked by Level
Maintainers or passive production the server can't see, so check how
an item is made before suggesting a target. AE2 picks the CPU, so
there's nothing to choose or comment on. Confirm before changing the
game.
- A snapshot of the base: the user and their role, the GTNH version,
CPUs, the last scan, patterns, power and stock rules.
- House rules admins write in a new AI assistant dialog (Settings),
which also shows the /mcp address and the latest tool calls.
Tools:
- plan_craft reports the requested item apart, labels rows as totals,
includes leftovers, and gives each row a plan sentence ("needs 48 in
all: 8 from storage (all of it), 40 crafted"), after a model read a
plan as crafting instead of using storage.
- get_item gives crafts_last_week. stock_rules gives set_by.
- The CPU wording in request_craft, request_status and craft_stats no
longer invites talk about CPUs.
- Every tool call is logged (mcp_calls, 30 days) and at INFO level.
server/discover is now private with a 5-minute TTL: its text depends on
the user. docs: using.md (what the assistant is told, house rules),
server.md, and CONTEXT.md with a checklist of assistant behaviours.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 4, 2026
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.
First of four PRs from the plan to make the MCP assistant smarter. Using it in claude.ai showed three mistakes, all from missing context:
The instructions (
gcm/mcp/instructions.py)Until now, assistants got one fixed paragraph. The instructions are now built for each connection from three parts:
instructions.md(773 words; a test caps it at 900, since it's in every conversation):crafts_last_weekanditem_historybefore suggesting a target; low-stock alerts are always safeserver/discoveris nowcacheScope: privatewith a 5-minute TTL, because its text depends on the user.Tools
plan_craft:requestedfield ("crafts 64; the 1,715 already in storage aren't used, AE2 never takes the requested item from storage").from_leftovers, which was missing before.plansentence, such as "needs 4 in all: 2 from storage (all of it), 2 missing".get_itemaddscrafts_last_week: AE2 jobs that made the item, including Level Maintainers', since their jobs run on CPUs too. Uses the newstore.crafts.item_crafts_since.stock_rulesaddsset_byfor each target.request_craft,request_statusandcraft_statsno longer invite talk about CPUs.AI assistant dialog (Settings, admins)
/mcpaddress with Copy.mcp_callstable, kept 30 days, and to the server log at INFO level. This is for tuning: what the model actually did, rather than screenshots.GET /api/admin/assistant,PUT /api/admin/assistant/rules,GET /api/admin/assistant/calls, all admin only.Docs
docs/using.md: "What the assistant is told", and house rules with examples.docs/server.md: the dialog.docs/CONTEXT.md: the design, and assistant behaviour checks, ten scenarios to re-run after changing the prompt. The first three are the mistakes above.Testing
tests/test_mcp_instructions.py(15 tests): the core text's length and contents; the snapshot before anything reports and with the fake game reporting; a failing part left out; house rules (appended, capped, admin-only routes, reachinginitializeanddiscover); plan rows, including the requested item with stock, batch leftovers, and partly-stocked and missing ingredients;crafts_last_week;set_by; the call log (logged, admin only, cut, pruned).initializeends with the rules. I checked screenshots in dark at desktop width and light at phone width.dev.py: the snapshot matched the fake game (10 CPUs, 8 busy; 51 item types; 14 patterns; 3 power machines; 3 targets, 1 failing). The plan sentences read as above.node --test, e2e (56),node --check, Lua (on 5.4), ruff, luacheck and shellcheck.CONTEXT.md, best run on the gtnh.network instance after deploying.🤖 Generated with Claude Code