Call from code
Make a read-only ClearLine call with the MCP TypeScript SDK.
Use this example when your application already has a user OAuth access token and an authorized account context. It reads the current ClearLine account and closes the connection.
Need interactive sign-in instead? Start with client setup.
1. Prepare the example
Use Node.js 22 or later. In a new directory, install the SDK version used by this example:
npm install @modelcontextprotocol/sdk@1.25.2
Save read-account.mjs in that directory.
2. Supply identity and account
Set these variables through your application's local environment or secret store:
| Variable | Value |
|---|---|
MCP_GATEWAY_URL | The direct ClearLine URL from the directory |
MCP_ACCESS_TOKEN | The user's current Magnite OAuth access token, issued for the gateway's audience and environment |
MCP_AUTH_CONTEXT | The authorized account value, such as clearline/dsp_sub/ACCOUNT_ID |
Replace ACCOUNT_ID with the account assigned to that user. Keep tokens out of source files and shell history.
In a backend, use the user access token supplied by your application's existing OAuth session. Pass that request's selected account with it. A long-lived worker must obtain renewed credentials from its authorization layer; this sample does not sign in or refresh tokens.
For a standalone interactive application, implement an OAuth provider using the MCP TypeScript SDK and the gateway's discovery metadata. Do not use a Streamr embed token, an ID token, or a teammate's token as a substitute.
3. Run a read
node read-account.mjs
The MCP result contains the current account. Check its name and ID against the intended account. The sample performs no writes and does not print credentials.
The SDK initializes a Streamable HTTP connection. Each request includes Authorization: Bearer … and x-auth-context. The script calls clearline_get_current_account, checks the MCP tool-error flag, prints the result, and closes the client.
An HTTP or JSON-RPC failure also rejects the SDK call. If the read fails, follow Troubleshooting before adding write operations.
Choose the right URL and tool name
| Connection | Path | Example tool name |
|---|---|---|
| One server | /mcp/server/SERVER_ID | get_products on Orchestration |
| All servers visible to you | /mcp | orchestration__get_products |
| A configured group | /mcp/group/GROUP_ID | orchestration__get_products |
Use the exact URL from Magnite and the names returned by tools/list. The connection's local name is just a label in your client; changing it does not change the server URL.
x-auth-contexttakes precedence over the picker selection. It selects an account; it does not grant access.- Read the token and account from the current request. Do not reuse one user's credentials or selection for another user.
X-MCP-Service-Tokenauthorizes metadata operations, including discovery. It does not authorizetools/call.- Bearer-based service integrations have their own provisioning requirements. Do not treat the static service-token header as a general automation credential.
Streamr developers can follow the integration walkthrough in the repository.

