Skip to main content
Glama
nakasyou

twitter_api_safe_relay_mcp

by nakasyou

twitter_api_safe_relay_mcp

A simple MCP server that forwards HTTP requests to twitter_api_safe_relay.

GitHub: nakasyou/twitter_api_safe_relay_mcp

Getting started

Start the relay server and set its URL in the environment:

TWITTER_RELAY_BASE_URL=http://localhost:6900 npx twitter_api_safe_relay_mcp

Example MCP client configuration:

{
  "mcpServers": {
    "twitter-api-safe-relay": {
      "command": "npx",
      "args": ["twitter_api_safe_relay_mcp"],
      "env": {
        "TWITTER_RELAY_BASE_URL": "http://localhost:6900"
      }
    }
  }
}

Related MCP server: MCP Relay Server

Tools

The server exposes two tools:

  • twitter_request_catalog: Searches the latest request catalog by operation name or path and returns executable templates.

  • twitter_api_request: Sends a request to the relay using a template.

Start by finding an operation in the catalog. The server fetches requests.ndjson on every catalog call, so updated query IDs and feature flags are picked up automatically.

{
  "query": "SearchTimeline",
  "limit": 5
}

Pass the returned request to twitter_api_request, changing only the values needed for your task, such as the search query, username, ID, or result count. Do not change features, fieldToggles, queryId, or operation-specific variable names.

Example twitter_api_request call:

{
  "endpoint": "/i/api/graphql/QUERY_ID/UserByScreenName",
  "method": "GET",
  "params": {
    "variables": {
      "screen_name": "example"
    },
    "features": {}
  }
}
  • endpoint: The path sent to the relay. Absolute URLs are not accepted.

  • method: GET (default), POST, PUT, PATCH, or DELETE.

  • params: URL query parameters. Object values are converted to JSON strings.

  • body: JSON request body.

  • headers: Optional HTTP headers.

The destination host is always restricted to TWITTER_RELAY_BASE_URL.

The /i/api prefix is added automatically to GraphQL catalog paths. It is not added to REST paths under /1.1 or /2. Confirm write operations before running them, then verify the result with a read operation. Note that GraphQL responses may contain errors even when the HTTP status is 200.

To use a different catalog source, set TWITTER_REQUESTS_CATALOG_URL.

Development and publishing

npm install
npm run typecheck
npm test
npm run build
npm publish

Once published, the server can be run on Node.js 18 or later with npx twitter_api_safe_relay_mcp. Bun users can run it with bunx twitter_api_safe_relay_mcp.

Releasing with GitHub Actions

Open the Release workflow in GitHub Actions, select the default branch, and choose patch, minor, or major. The workflow calculates the next version from the latest version on npm, runs the tests and build, publishes the package to npm, and creates a GitHub Release.

Before using the workflow, publish the package to npm once and configure a Trusted Publisher for it. The current workflow calculates the next version from the latest version available on npm, so it cannot perform the initial publication of a new package.

  • Provider: GitHub Actions

  • Organization or user: nakasyou

  • Repository: twitter_api_safe_relay_mcp

  • Workflow filename: release.yml

  • Allowed action: npm publish

No long-lived npm token is required. The workflow uses a GitHub-hosted runner, Node.js 24, and npm OIDC Trusted Publishing.

Available Tools

2 tools
twitter_api_requestA

Execute one request against the signed-in Twitter/X relay. Get a current template from twitter_request_catalog first: GraphQL query IDs, features, field toggles, and variable names are versioned and operation-specific. Reads and writes use the same relay; confirm before side effects and verify writes with a follow-up read. HTTP 200 responses may still contain GraphQL errors.

ParametersJSON Schema
NameRequiredDescriptionDefault
bodyNoJSON request body
methodNoGET
paramsNoURL query parameters. Object values are JSON-encoded.
headersNoOptional request headers
endpointYesRelay endpoint path, e.g. /i/api/graphql/... or /1.1/search/typeahead.json

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the full burden. It discloses that reads and writes share the relay, warns about side effects ('confirm before side effects'), advises verifying writes, and explicitly warns that HTTP 200 may still contain GraphQL errors. This is meaningful behavioral context beyond what schema could convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three tight sentences, each earning its place: purpose, workflow guidance referencing the catalog, and a critical behavioral warning about GraphQL errors. Zero filler, front-loaded with the actionable catalog-first directive.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

It's a general-purpose request relay tool with 5 params and no output schema. The description wisely points to twitter_request_catalog for operation-specific details, which offloads completeness. The side-effect verification guidance is appropriate for a mutation-capable tool. Lacks some detail about response handling given no output schema, but the catalog referral covers that gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 80%, which is high, so the baseline is 3. The description adds some context about endpoint structure (e.g., '/i/api/graphql/...') but doesn't go beyond the schema's own descriptions. With high schema coverage, the description needn't compensate heavily, though it could note that method defaults to GET and confirms the params/headers semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes a single request against a Twitter/X relay, with a specific verb ('execute one request') and resource ('signed-in Twitter/X relay'). It differentiates itself from the sibling twitter_request_catalog by instructing to get templates from that catalog first, making the distinction between the two tools explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage context: get a current template from twitter_request_catalog first, confirm before side effects, and verify writes with follow-up reads. It doesn't explicitly state when NOT to use this tool, but the alternative is clearly referenced and the workflow (catalog-first) is well articulated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

twitter_request_catalogA

Search the current Twitter/X request catalog by operation name, path, method, or request content. Returns ranked templates already converted to the argument shape accepted by twitter_api_request. Use operation-like terms such as SearchTimeline, UserByScreenName, TweetDetail, CreateTweet, friendships, blocks, or lists. Fetches the upstream NDJSON on every call so query IDs and feature flags stay current.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of ranked templates to return.
queryYesCase-insensitive search text; all space-separated terms must match.

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and discloses significant behavioral details: it fetches the upstream NDJSON on every call (network dependency, ensures freshness), keeps query IDs and feature flags current, and returns ranked templates. This transparency about the live-fetch behavior and output format goes well beyond what's needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences cover purpose, usage examples, output format, and behavioral transparency without waste. It's front-loaded with the core purpose in the first sentence and efficiently packs useful operational details into the remaining two. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite no output schema, the description compensates by stating results are ranked templates in the argument shape for twitter_api_request, which sufficiently communicates the return type for a search tool. With a simple 2-param schema at 100% coverage and rich behavioral disclosure, the description is complete for this tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and both parameters have descriptions in the schema. The description adds context that query terms must match all space-separated terms (AND semantics beyond case-insensitivity) and that results are ranked templates. This adds marginal value beyond the schema but is light on parametrization details like how limit interacts with ranking.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches a catalog by operation name, path, method, or content, with specific operation examples (SearchTimeline, UserByScreenName, etc.). It also clarifies the key output property: templates already converted to the argument shape for twitter_api_request, which distinguishes its purpose from the sibling tool that actually executes requests.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage context: use operation-like terms to search the catalog. It names the sibling tool (twitter_api_request) and frames results as pre-converted arguments for it, establishing when to use this tool (for discovering templates) vs. the sibling (for making requests). However, it doesn't explicitly state when NOT to use it or list alternative search approaches.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.2
    • First observedtwitter_api_request
    • First observedtwitter_request_catalog

TDQS

A4.1/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have completely distinct purposes: one fetches/curates request templates from the catalog, the other executes a single request against the relay. There is no overlap or ambiguity between them.

Naming Consistency3/5

Both tools use a similar 'twitter_' prefix, but one uses 'request' and the other 'request_catalog', which is a mild inconsistency in granularity. The names are readable but the pattern isn't perfectly parallel—'twitter_api_request' vs 'twitter_request_catalog' mixes the placement of 'api' and 'request'.

Tool Count2/5

Two tools feels extremely thin for a Twitter/X API surface, which is vast (timelines, tweets, users, friendships, DMs, media, trends). While the catalog tool cleverly bundles the numerous request types into a searchable interface, the overall surface is still very limited given the breadth of the domain.

Completeness3/5

The two-tool design is a clever pattern: the catalog surfaces templates for any operation and the executor handles them, so in principle the coverage is as deep as the catalog. However, there are no helper tools for authentication setup, session management, or error diagnosis, and the design forces agents to do two calls for every single operation, creating friction.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Model Context Protocol server that enables programmatic interaction with Twitter API, allowing users to post tweets, search for content, and retrieve user timelines through standardized MCP tools.
    9 npm
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Exposes provider-specific tools and relays HTTP requests to configured providers like Supabase, Vercel, and Context7, enabling interaction with multiple external APIs through a unified MCP interface with configurable authentication and access controls.
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI agents to safely interact with external services (HTTP, GraphQL, gRPC, Bash, SQL) using HCL templates and OS keychain secrets, preventing prompt injection by keeping request details from the LLM.
    113
    Apache 2.0
  • A
    license
    C
    quality
    B
    maintenance
    Read-only Twitter API server with bookmark and like management, plus anti-rate-limit protection.
    38
    MIT