Skip to main content
Wire any agent — any language, any framework — to the Nasiko MCP gateway so it can discover and call every tool a user has connected, with zero hardcoded tool names. If your agent runs on Nasiko, it doesn’t need an MCP SDK, a special client library, or any per-connector code. It needs exactly two things at deploy time, and one small tool-calling loop. This page covers that, in whatever framework you’re already using — LangChain, LangGraph, CrewAI, Google ADK, the raw OpenAI SDK, Anthropic’s SDK, or a hand-rolled agent in Node, Rust, or Go.
For the router to work, each agent is given two environment variables at deploy time: OPENAI_BASE_URL (the gateway’s address, not api.openai.com) and OPENAI_API_KEY — not a real provider key, but a signed ticket that says “I am agent X, acting on behalf of user Y.” Your agent framework already reads both of these to construct its LLM client, so most of the wiring is already done for you — this page is about the tool-calling half, not the LLM half.

How it works

Every tool call your agent makes goes through one HTTP endpoint — MCP_GATEWAY_URL — using plain JSON-RPC 2.0. There is no MCP client SDK dependency: you POST a JSON body and read a JSON body back. The two methods you need are tools/list (what’s available right now, for this user, for this agent) and tools/call (invoke one). Authentication is a single header, x-nasiko-agent-token — a short-lived, per-request credential minted by the platform and forwarded to your agent on every inbound call. You read it once, and forward the exact same value on every outbound call you make to the gateway during that request.
This token is not your agent’s static API key. It’s minted fresh per inbound request and expires in minutes. Never cache it across requests, never log its full value, and never forward it anywhere except the gateway.

Quickstart

1

Read the gateway URL

Injected automatically into your agent’s environment at deploy time — already includes the full path. If it’s empty, your agent either isn’t deployed with the gateway enabled, or was deployed before it was — skip tool-calling gracefully rather than erroring out.
2

Read the inbound delegation token

Every request that reaches your agent carries x-nasiko-agent-token as a header. Pull it out using whatever your framework exposes for inbound headers.
If your framework doesn’t expose inbound headers anywhere in the handler context, wrap it in middleware that copies them somewhere your handler can reach:
No token present? Skip tool access for this request — don’t crash.
3

Call the gateway

One helper function covers both methods you’ll ever need.
Never hardcode tool names — they’re per-user and change whenever a connector is added or removed. Always call tools/list fresh. See Protocol reference for exact request and response shapes.
4

Merge into your LLM's tool list

Add two function-calling tools alongside whatever tools your agent already has — don’t replace them.
Dispatch by name in whatever tool-execution code you already have — one branch, nothing else changes:
Name collision with a tool you already have? Rename either side — there’s no fixed contract, mcp_list_tools and mcp_call_tool are just this page’s convention.LLMs tend to refuse a tool instead of trying it when they’re not 100% sure it’s relevant. Push back in your system prompt:
“Always call mcp_list_tools first. If any tool plausibly relates to the request, call it with best-effort arguments — don’t ask for clarification, don’t skip it because you’re unsure. Only say nothing’s available after actually trying.”
5

Bound the loop and handle timeouts

If you’re not using a framework with a built-in agent loop, cap the manual one and make sure a mid-loop cutoff doesn’t silently drop results.
Use 30–60s or longer timeouts for gateway calls, not a short default — real connectors (Notion, Slack, and the like) can be genuinely slow. A caught-but-unmessaged timeout often logs as an empty string and looks to the user like a silent crash.If you’re using LangChain, LangGraph, CrewAI, or Google ADK, skip this step entirely — see Framework integrations below, your framework already runs this loop for you.

Protocol reference

Plain JSON-RPC 2.0 over a single endpoint (MCP_GATEWAY_URL), always POST, always HTTP 200 — a failed tool call is a JSON-RPC error object in the body, not an HTTP error status.

Methods

Error codes

Framework integrations

Pick your framework. In every case, the pattern is the same: wrap the two gateway calls as tools your framework already knows how to call, and add them to whatever tool list you already have.

LangChain

LangGraph

mcp_list_tools and mcp_call_tool are the same @tool-decorated functions from the LangChain section above — LangGraph’s prebuilt ReAct agent accepts the same tool objects.

CrewAI

Same pattern as LangChain: wrap the two functions as @tool-decorated CrewAI tools, add them to the agent’s tools list, and set max_iter on the agent to bound the loop.

Google ADK

ADK derives a tool’s schema from a plain Python function’s type hints and docstring — no decorator needed, just pass the functions directly:

OpenAI Agents SDK and raw SDK

See Quickstart above — the manual loop shown there is the raw-SDK pattern. If you’re on the OpenAI Agents SDK specifically, wrap the two functions with @function_tool and add them to your Agent’s tools list the same way; the SDK’s own Runner loop handles the rest.

Anthropic Claude (native tool use)

Claude’s native tool-use format isn’t OpenAI-compatible: the schema field is input_schema (not parameters), and tool results go back as a tool_result content block, not a role: tool message.

Node.js and TypeScript

No SDK dependency needed — a raw fetch call works with any Node framework or agent library:

Rust

Local testing

Test with curl before wiring up any agent code — this isolates “is my token and URL correct” from “is my agent code correct.”
A non-empty result.tools array means your token and URL are both correct — any remaining problem is in your agent code, not the gateway. A -32602 means your token is invalid, expired, or missing; grab a fresh one from a real inbound request rather than reusing an old value.

Security

  • Never log the full token value — log token present: true/false only.
  • Never forward the token to a third-party service, or echo it back to the end user in a response.
  • Never cache or persist the token — it’s minted fresh per inbound request and expires in minutes by design.
  • The token is the only credential this endpoint accepts. There’s no separate API key to rotate or manage.

Troubleshooting

Checklist

Before calling your integration done, verify each of these against a real deployment:
  • MCP_GATEWAY_URL missing — agent still answers plain questions, no crash
  • Token missing — same, graceful skip
  • tools/list returns tools when the user has a connector configured
  • tools/call result reaches the LLM and is used in the final answer
  • No connector for the topic — an honest “nothing available,” never a made-up answer
  • A bad tool call reports the real error, with no silent fallback to something else
  • A slow tool produces a clean timeout message, not a blank crash
  • Pre-existing tools still work unchanged, and the LLM can call one of yours and one gateway tool in the same turn