- Tenant — on whose behalf the agent can call integrations
- Toolset — which integrations and tools it can use
- Discovery — how it finds and calls those tools
- A sales agent with a user’s personal Gmail & Google Calendar, and a read-only org-wide Salesforce connection
- A finance agent with a few read-only tools on an org’s accounting system, and read & write access to a team’s Slack
- A developer agent with a team’s Linear access and a user’s personal GitHub access
We are quickly expanding agent sessions, follow our changelog for announcements and improvements!
Quickstart
1
Create a session from your backend
By default, a session covers every tool on the integrations the tenant has a connection for.To define the tenant, select the connections the agent may use with tag selectors:Requires an API key with the
environment:agent_sessions:write scope. See API key scopes.This returns a ready-to-use session:2
Pass the MCP server to your agent
Pass the The Responses API never stores the Your agent can now use every tool the session exposes.
mcp_url to your agent, with the session_token as bearer auth:- OpenAI
- Anthropic
- Vercel AI SDK
- LangChain
- Mastra
authorization value, so send it on every request.Session basics
Creating a session
Create a session with the tools and access your agent needs.session_id and session_token. The token is a scoped access token for that session — treat it as a secret, and keep session durations as short as your use case allows.
Session MCP server
Every session exposes its own MCP server at itsmcp_url. It speaks Streamable HTTP and authenticates with the session_token as a bearer token, so any MCP-capable agent or client can connect to it.
tools/list returns the enabled meta tools plus the pinned tools, paginated 50 at a time through nextCursor. Searchable tools are callable but not listed, and the agent finds them with the nango_tool_search meta tool.
Terminating a session
Sessions are immutable and cannot be extended. They expire on their own onceexpires_in is up, and you can end one early with DELETE /sessions/{session_id}:
environment:agent_sessions:write scope, the same one session creation uses.
session_token together with the session, so the session’s MCP server answers 401 from that point on. A tool call already in flight is not cancelled.
Terminating is idempotent. A session that has already ended keeps its original ended_at and reason, so terminating it again returns the same response. An unknown session, or one from another environment, returns a 404.
Recreate the session with the same parameters if you need it again.
Tenant
The tenant defines on whose behalf the agent may act. For example: use a specific user’s Gmail credentials, but the org-wide credentials for Salesforce. You express this with Connection tag selectors underany, which the session resolves to the right Connections in Nango. Tags within one entry are ANDed, entries are ORed, up to 10 entries.
Here, organization_id, workspace, and user_id are Connection tags we set up for our application.
Resolving ambiguity
If the selectors match two or more connections on the same integration, there is no way to tell which one the session should use. Creation fails withambiguous_connections, and no session is created:
- Add tags to the selector until it matches exactly one connection per integration.
- Use
pinnedto name the connection to use for that integration.
pinned_connection_not_matched. Pinning a connection that does not exist fails with unknown_pinned_connection.
You can also use pinned without any any selectors, if you already know the exact connections you want to use.
An integration that matches no connection does not fail creation. It appears in the toolset as connected: false, and its tool calls fail with a missing authorization error.
Currently there is no way for the agent to ask the user to connect an unconnected integration. Let us know if you need this and we are happy to prioritize it.
Toolsets & tools
toolset defines which tools are available to the agent.
The toolset is a subset of the Integrations that are enabled in your Nango environment.
"*"on an integration means every action function on itallowmakes the integration an allowlist, where"*"means every tooldenyalways subtracts from whateverallowgave- To deny an integration entirely, leave it out of the toolset
toolset: "*"at the top level means every integration in the environment- Leaving
toolsetout entirely means every integration the tenant resolved a connection for, which is narrower than"*"
unsupported_function_type, an unknown integration with unknown_integration, and an unknown tool with unknown_tool. Any error fails creation, so a session is either fully valid or not created.
Pinned tools
By default, everything in the toolset is searchable with thenango_tool_search meta tool, but none of it is listed in the MCP server’s tool list. This keeps a large toolset from filling the agent’s context with hundreds of definitions it will never call.
pinned_tools exposes specific tools in that list, so they are in context as soon as the agent loads the server:
tool_not_in_toolset.
Meta tools
Meta tools are Nango’s own tools. They are always pinned to the MCP server’s tool list.nango_tool_search and nango_execute default to true, nango_proxy to false. Set them on session creation with meta_tools:
nango_tool_search
Takes a plain-languagequery describing what the agent wants to do.
guidance for the agent, matches for the best hits, and related tools for weaker matches to narrow down. Each match names the tool to pass to nango_execute, its integration, action, and provider, whether it is listed, and its connection status.
Only a best match includes input, its argument schema — a weak match is a lead, not something to call yet.
nango_execute
Runs one of the session’s tools by name, on the connection the session resolved for that integration.nango_proxy
The escape hatch for when no tool in the session covers what the agent needs. It makes an authenticated HTTP request to a provider API on the connection the session resolved for that integration, so the agent names an integration and never a connection.query_params and headers. Nango authenticates the request from the session’s connection, so credential headers are rejected rather than forwarded, including the provider’s own (x-api-key and the like) alongside authorization.
The integration has to be one in the session’s toolset with a resolved connection, but the path is not restricted to what the toolset exposes. That is why nango_proxy is off by default: turning it on lets the agent reach any endpoint of a connected integration.
The result is the provider’s status, headers and body, for JSON or UTF-8 text responses up to 5 MB. Binary and larger responses are not supported, and neither is file upload. Use the HTTP proxy for those.