Skip to content

Split override templates into a light index and a per-template detail tool - #4

Open
92Infinitus92 wants to merge 6 commits into
feat/pump-protocolfrom
feat/mcp-template-index
Open

Split override templates into a light index and a per-template detail tool#4
92Infinitus92 wants to merge 6 commits into
feat/pump-protocolfrom
feat/mcp-template-index

Conversation

@92Infinitus92

@92Infinitus92 92Infinitus92 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

get_override_templates returned every template in full: properties, PDA layout, the whole constant catalog, and a ~160KB IDL inlined per template. An agent had to load all of that just to see what was available.

This splits it in two:

  • get_override_templates now returns a light index - id, name, description, protocol, account type, tags, and a hasLlmContext flag. No properties, no IDL, no inlined options.
  • get_override_template(templateId) returns one template's full detail, with each constant summarized as {label, description, optionsCount} instead of the raw option list.

The flow is index → pick → detail → search_constant_options for a concrete value → create_scenario, and the guidance text walks the model through that order.

Stacked on #3 (base feat/pump-protocol); I'll retarget to develop once that merges.

Greptile Summary

The PR replaces the heavyweight override-template listing with an index and introduces a separate tool for retrieving one template’s details.

  • Adds lightweight index serialization with template metadata and a context-availability flag.
  • Adds get_override_template(templateId) for properties, address, summarized constants, and LLM context.
  • Updates MCP guidance, the override-template resource, and tests for the index-to-detail workflow.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/mcp/src/surfpool/mod.rs Splits template discovery from full-detail retrieval, updates tool guidance and resource output, and adds focused coverage for both response shapes.

Sequence Diagram

sequenceDiagram
    participant Agent
    participant Index as get_override_templates
    participant Detail as get_override_template
    participant Search as search_constant_options
    participant Scenario as create_scenario
    Agent->>Index: List lightweight template metadata
    Index-->>Agent: IDs, descriptions, tags, context flags
    Agent->>Detail: Fetch selected templateId
    Detail-->>Agent: Properties, address, summarized constants
    Agent->>Search: Resolve a constant option
    Search-->>Agent: Concrete option value
    Agent->>Scenario: Create scenario with selected values
    Scenario-->>Agent: Scenario result
Loading

Reviews (2): Last reviewed commit: "Split override templates into a light in..." | Re-trigger Greptile

92Infinitus92 and others added 3 commits August 7, 2026 12:08
* feat(scenarios): extend the pyth price feed template beyond price

The pyth-price-feed-v2 template exposed only feed_id and price, so scenarios
could not express staleness or confidence-band cases that lending/PMM logic
actually reads. Adds the remaining PriceFeedMessage fields (conf, exponent,
publish_time, prev_publish_time, ema_price, ema_conf) and posted_slot as
template properties, and extends llm_context with field semantics, a staleness
recipe, and the Surfnet clock rules (timeTravel takes milliseconds, the
simulated clock only moves forward).

Covered by a forging unit test against a real 134-byte PriceUpdateV2 account:
all eight writable fields change to values that differ from the fixture's,
bytes before price are asserted untouched, trailing padding is preserved.

* docs(rpc): document surfnet_timeTravel units and direction

absoluteTimestamp is consumed in milliseconds while the Clock sysvar exposes
seconds, and jumps are forward-only; the doc comment said neither, which cost
a debugging session to rediscover empirically.

* feat(mcp): compact override templates and add search_constant_options

get_override_templates inlined every constant option (hundreds of price feeds,
duplicated across templates), producing a ~1.86 MB payload that overflowed LLM
context windows and TPM limits. Constants are now summarized as
{label, description, optionsCount} — 85x smaller measured — and the new
search_constant_options tool resolves concrete values via case-insensitive
search with stable sorted paging (MAX_SEARCH_RESULTS) and self-correcting
errors for unknown template ids or constants. The str:///override_templates
resource shares the same serialization through compact_template_json, so both
MCP surfaces stay compact.

Adds the first tests of the mcp crate: tool error paths, case-insensitive
matching, truncation reporting, and a guarantee that no template leaks inlined
options.

* fix(cli): return JSON 404 for unknown /v1 paths instead of the SPA fallback

The studio SPA catch-all answered any unknown GET — including API misses like
GET /v1/scenarios/{id}, which has never existed — with index.html and HTTP 200.
Clients then failed deep in JSON parsing ("Unexpected token '<'") instead of
seeing a clean 404, which is how a tag-wiping frontend bug shipped unnoticed.
Unknown /v1/* paths now get {"error":"not found"} with 404; page routes and
static assets keep the SPA fallback.

Route registration moved into configure_api, shared between the server and the
new HTTP test, so the load-bearing registration order (real endpoints before
the /v1 catch-all scope) is asserted on the exact code production runs.

* test(cli): cover non-GET methods in the /v1 guard test

Review feedback: the guard's default_service is method-agnostic, but the test
only exercised GET. A POST to an unknown /v1 path now asserts the JSON 404 too.

* fix(types): resolve u16 PDA seeds from a constant option value

Constant options carry their value as a string, so Raydium amm_config_index
never derived its PDA and the override was skipped with only a log line.

* refactor(mcp): take templateId the way the response names it

The search tool asked for template_id while its payload returns templateId. A
test covers both the schema a model reads and the deserializer behind it.

* docs(rpc): name documented fields the way they serialize

Six documented fields were snake_case while the wire is camelCase. fetch_before_use
was the harmful one: it is serde(default), so a client following the docs got HTTP
200 and an override stored with fetchBeforeUse false — no fresh fetch, and a skip
when the account was not already in the SVM.

* docs: make the cheatcode catalog match what the RPC accepts

The registerScenario schema omitted the required tags and typed account as a
string, so a request following it failed deserialization. The clock cheatcodes
were missing from the catalog the MCP tool points models at, and the EpochInfo
examples showed snake_case. The Pyth staleness workflow now says how to read the
simulated clock, since pauseClock returns no timestamp.
…storing duplicates (#2)

The MCP tools called HTTP through reqwest's blocking client from async tool
functions, so a create_scenario the server had accepted could still be reported
as a connection failure; the model retried and stored a duplicate. They now use
the async client, and POST /v1/scenarios treats an identical retry as a no-op
while rejecting different content under a taken id with 409.
@92Infinitus92 92Infinitus92 self-assigned this Aug 11, 2026
@92Infinitus92

Copy link
Copy Markdown
Collaborator Author

@greptileai

Give every field of the pump-global, pump-amm-pool-state and pump-amm-global-config
templates a label and description (they were bare name lists), and add a field reference
to both pump READMEs. Expose Global.withdraw_authority so a migrate can be driven on a
fork. Trim the bonding-curve llmContext of its redundant worked example and the niche
cost formula.
@92Infinitus92
92Infinitus92 force-pushed the feat/mcp-template-index branch from 7d7e45d to 9ecf2de Compare August 11, 2026 10:11
Prepare a near-complete Token-2022 pump.fun curve so one buy graduates it:
a graduation calculator/validator, the pump-token-2022-curve-balance template
with a tail-safe Token-2022 amount write, the /v1/scenarios/pump-graduation
endpoint and MCP tool, and an ignored buy_v2 -> migrate_v2 -> sell lifecycle
harness backed by a frozen snapshot fixture.
@92Infinitus92
92Infinitus92 force-pushed the feat/mcp-template-index branch from 9ecf2de to 3ce7caa Compare August 12, 2026 12:40
@92Infinitus92
92Infinitus92 marked this pull request as ready for review August 12, 2026 12:40
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.

1 participant