anomalyco / anomalyco/opencode
Feature request — cost/priority metadata for MCP tools; agents default to the most expensive tool
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Version: opencode 1.18.14, Linux
Problem
When an MCP server exposes multiple tiers of the same capability at different prices (e.g., a search API with sonar at $1/$1 per M tokens, sonar-pro at $3/$15, and a deep-research mode at $2/$8 + extra fees), the LLM has no signal to prefer the cheap tier. It defaults to the most capable-sounding — and therefore most expensive — tool.
Concretely:
- Tools are only controllable via
permission(allow/ask/deny) andtools(enable/disable). There is no way to express cost, priority, or a "default to this one" preference on a tool. - Description text is the only discriminator, and models reliably gravitate to "most comprehensive" descriptions even when they say "use ONLY as a last resort."
- In my session, the tools surfaced to the model in the order
sonar_deep_research→sonar_reason→sonar_search_pro→sonar_search— the most expensive listed first, despite being defined cheapest-first in the server. Whatever the sort, it's working against cost-awareness.
Suggested solutions (any would help)
- Cost/priority field on tool definitions — e.g. an optional
costorpreferencehint (MCP server-provided or config-level) that biases selection and/or sorts cheap-first. - Per-agent tool ordering — let config express a preferred order for tools, applied to the tool list the model sees.
opencode mcp listsurfacing tool count/order — so users can at least see what order the model is presented.- A config-level "default tool" per MCP server — e.g.
"tools": {"perplexity": {"default": "sonar_search"}}.
FYI — how we're working around it today
We run a single local MCP server (~/.config/opencode/mcp/perplexity/server.js) exposing the four tiers as explicitly-named tools with no auto-escalation — each tool calls exactly the model it's named for, so the tool choice is the cost choice:
sonar_search→ sonar ($1/$1)sonar_search_pro→ sonar-pro ($3/$15)sonar_reason→ sonar-reasoning-pro ($2/$8)sonar_deep_research→ sonar-deep-research ($2/$8+)
(We replaced the third-party perplexity-mcp npm package, which silently auto-escalated based on query keywords — that made cost control impossible.)
The remaining mitigation is a skill (perplexity-cost-aware) that instructs the model to start with sonar_search and escalate only when the cheap answer is insufficient. It works intermittently — it's advisory and only helps if the model loads it before the first call. A structural mechanism in opencode would be far more reliable than description text and skills.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name repository files or tests. Start by tracing MCP tool discovery, ordering, configuration handling, and the opencode mcp list entry point; first clarify which proposed behavior is intended. Done should include a defined cost, priority, ordering, or default-tool mechanism with user-visible behavior and coverage for the selected configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100