WEIR

OpenCode MCP Setup: Add X (Twitter) Data and Sign In

Add a remote MCP server to OpenCode in opencode.json, sign in with opencode mcp auth, hide tools you don't need and see what a real X search cost us.


Published · Updated · 7 min read

Cover image: X research inside OpenCode

OpenCode MCP setup for a remote server is one opencode.json entry with "type": "remote" and a URL, then opencode mcp auth to sign in.

This guide adds Weir, so OpenCode can search X (Twitter) and read posts, threads and profiles while it works in your repo. Weir only reads, so it never posts as you. We run Weir.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "weir": { "type": "remote", "url": "https://api.weirapp.io/mcp" }
  }
}

OpenCode MCP setup: add Weir and sign in

OpenCode reads MCP servers from the mcp key of its config, so there's nothing to install.

  1. Add WeirPaste the JSON above into opencode.json in your project root. For every project, use ~/.config/opencode/opencode.json.
  2. Sign inRun opencode mcp auth weir. Your browser opens, you sign in to Weir and approve.
  3. Check itRun opencode mcp list. Weir should show as connected.
  4. Ask the free questionStart opencode and ask "use weir: what's my usage?" It calls get_usage, which costs nothing.

Why a sign-in? Weir answers any request without a token with 401. OpenCode's docs say it then starts OAuth, registers itself with the server and stores the tokens in ~/.local/share/opencode/mcp-auth.json.

Is the project file safe to commit? Yes, when it holds only the URL. Each teammate signs in to their own Weir account, and OpenCode merges the project file with their global one.

Prefer a command? Run opencode mcp add, pick Remote and paste the URL. If it asks for a client ID, say no: Weir registers OpenCode by itself.

OpenCode 1.19.3's source also takes flags, which write to your global config:

opencode mcp add weir --url https://api.weirapp.io/mcp

OpenCode's main docs show only the guided form, so check opencode mcp add --help on your version first.

OpenCode MCP config with an API key

A key suits CI and remote machines, where nobody can click through a browser. Create one under API keys in your Weir dashboard and export it as WEIR_API_KEY.

{
  "mcp": {
    "weir": {
      "type": "remote",
      "url": "https://api.weirapp.io/mcp",
      "oauth": false,
      "headers": { "Authorization": "Bearer {env:WEIR_API_KEY}" }
    }
  }
}

OpenCode fills in {env:WEIR_API_KEY} from your shell when it loads the config, so the key never sits in the file.

Setting oauth to false stops the browser sign-in. OpenCode's docs advise it for servers you reach with a key.

How do you limit OpenCode MCP tools?

Use a permission rule on the tool names. OpenCode names each MCP tool <server>_<tool>, so Weir's search becomes weir_search_x.

MCP tools add to the model's context, OpenCode's docs warn. Weir brings 44 on a default connection: 25 for X, 12 for Reddit, 3 free account tools and 4 that read your monitors.

{
  "permission": {
    "weir_*": "ask",
    "weir_*reddit*": "deny"
  }
}
  • The second rule hides Reddit. Every Reddit tool name contains "reddit", and OpenCode 1.19.3's source drops a tool from the model's list when its last matching rule is deny.
  • The first rule asks before each call. OpenCode runs tools without asking by default. With ask, you read the limit before you spend credits.
  • Order matters. OpenCode's docs say the last matching rule wins, so keep the wide rule first.

OpenCode's MCP page still shows the older tools block with false. Its permissions page says that form is deprecated since v1.1.1, though it still works.

Want Weir off for a while? Set "enabled": false on its entry. OpenCode's docs say that keeps the config but skips the server at startup.

Can OpenCode read X (Twitter)? A worked task

Yes. Once Weir is connected, the model picks the tool and fills in the arguments.

Say you're about to add the GitHub MCP server to a project, and you want GitHub's latest news first. Paste this into OpenCode:

use weir: find what @github posted about MCP in the last 30 days.
Skip reposts. Save each post with its likes and link to notes/github-mcp.md.

The tool it needs is weir_search_x, with fromUsers, query and since. We ran that call through Weir's MCP server on 22 October 2026, at limit: 3:

→ search_x {"fromUsers": ["github"], "query": "MCP -filter:nativeretweets",
            "since": "2026-09-22T00:00:00Z", "limit": 3}
← 1 post · 2 credits (1 + 1 × 1) · nextCursor set
  2026-09-23  94 likes  59,139 views
  "Should you review your AI-generated code? Is RAG over? Did Skills
   make MCP obsolete? The GitHub Podcast responds to these hot takes"

One post matched: a GitHub Podcast episode that asks whether Skills made MCP obsolete.

X search returns reposts by default. The -filter:nativeretweets part of the query drops them, which is how "skip reposts" works.

The reply still carried a cursor. Weir's docs say only a null nextCursor means the end, so a second call could find more. To test search words before a run, see our Twitter keyword research guide.

2credits for our 1-post search
11credits for a 10-post search
0credits for get_usage
5,000free Weir credits every month

Weir bills 1 credit per call plus 1 per X post, and failed calls are free. Paid packs start at $5 for 25,000 credits and never expire, as of October 2026. Your model costs are separate and depend on the provider you use in OpenCode. Every Weir rate is on our pricing page.

If it doesn't work

  • opencode mcp list says "needs authentication". Run opencode mcp auth weir.
  • Sign-in fails. Run opencode mcp debug weir, which tests the connection and the OAuth discovery. We haven't tested Weir's sign-in inside OpenCode, so if it keeps failing, use the key setup.
  • The browser can't reach 127.0.0.1:19876. OpenCode's source listens there for the sign-in callback. Sign in on the machine that runs OpenCode, or use a key over SSH.
  • 401 unauthorized with a key. Export WEIR_API_KEY in the shell that starts OpenCode, and check the key isn't revoked.
  • The model never calls Weir. Start the prompt with "use weir", as OpenCode's docs suggest, or say so in AGENTS.md.
  • A config uses mcp.servers. That's the layout in OpenCode's V2 docs. This guide uses the flat layout from the main docs.
  • Weir returns 402. Your credits ran out, and retrying won't help. Add credits or wait for next month's grant.

When not to use Weir

  • OpenCode has to post, reply or DM. Weir is read-only, so pick a tool with write access to your account.
  • You want your private data. Weir reads public posts, not your bookmarks, DMs or home timeline.
  • Price per post matters most. TwitterAPI.io lists $0.15 per 1,000 tweets as of October 2026, less than our $5 pack.
  • You need a guarantee. Weir isn't licensed by X or affiliated with it, so access can change.

FAQ

How do I add an MCP server to OpenCode?

Add an entry under mcp in opencode.json. A remote server needs "type": "remote" and a url. A local one needs "type": "local" and a command array. Or run opencode mcp add and answer its questions.

What does opencode mcp auth do?

It runs the OAuth sign-in for a remote server. OpenCode opens your browser, you approve, and it saves the tokens in ~/.local/share/opencode/mcp-auth.json. opencode mcp logout weir removes them, and opencode mcp auth list shows each server's sign-in status.

Where does the opencode mcp config live?

In opencode.json at your project root, or in ~/.config/opencode/opencode.json for every project. OpenCode merges the two, and the project file wins where they clash.

Can OpenCode post to X through Weir?

No. Weir only reads public X data, so nothing can post, like or follow through it. To post, you need a tool that holds your own X account's access.

Sources