Quickstart

Create your first MCP server

Model Context Protocol (MCP) is an open-source standard for connecting AI applications to external tools. All the 500+ tools available in Composio are also available as MCP servers.

Composio lets you create MCP servers that handle authentication (OAuth, API keys), generate unique URLs for each user, and control which tools are exposed. You can combine multiple toolkits in a single server.

Composio MCP servers only support Streamable HTTP transport.

Install the SDK

First, install the Composio SDK for your preferred language:

pip install composio
npm install @composio/core

Create an MCP server

Initialize Composio

from composio import Composio

# Initialize Composio
composio = Composio(api_key="YOUR_API_KEY")
import { class Composio<TProvider extends BaseComposioProvider<unknown, unknown, unknown> = OpenAIProvider>
This is the core class for Composio. It is used to initialize the Composio SDK and provide a global configuration.
Composio
} from '@composio/core';
// Initialize Composio const const composio: Composio<OpenAIProvider>composio = new new Composio<OpenAIProvider>(config?: ComposioConfig<OpenAIProvider> | undefined): Composio<OpenAIProvider>
Creates a new instance of the Composio SDK. The constructor initializes the SDK with the provided configuration options, sets up the API client, and initializes all core models (tools, toolkits, etc.).
@paramconfig - Configuration options for the Composio SDK@paramconfig.apiKey - The API key for authenticating with the Composio API@paramconfig.baseURL - The base URL for the Composio API (defaults to production URL)@paramconfig.allowTracking - Whether to allow anonymous usage analytics@paramconfig.provider - The provider to use for this Composio instance (defaults to OpenAIProvider)@example```typescript // Initialize with default configuration const composio = new Composio(); // Initialize with custom API key and base URL const composio = new Composio({ apiKey: 'your-api-key', baseURL: 'https://api.composio.dev' }); // Initialize with custom provider const composio = new Composio({ apiKey: 'your-api-key', provider: new CustomProvider() }); ```
Composio
({
apiKey?: string | null | undefined
The API key for the Composio API.
@example'sk-1234567890'
apiKey
: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.string | undefinedCOMPOSIO_API_KEY
});

Create server configuration

Before you begin: Create an auth configuration for your toolkit.

Create an MCP server with your auth config. You can also set list of specific tools to enable across all toolkits.

# Create MCP server with multiple toolkits
server = composio.mcp.create(
    name="mcp-config-73840", # Pick a unique name for your MCP server
    toolkits=[
        {
            "toolkit": "gmail",
            "auth_config": "ac_xyz123"  # Your Gmail auth config ID
        },
        {
            "toolkit": "googlecalendar",
            "auth_config": "ac_abc456"  # Your Google Calendar auth config ID
        }
    ],
    allowed_tools=["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL", "GOOGLECALENDAR_EVENTS_LIST"]
)

print(f"Server created: {server.id}")
print(server.id)
// Create MCP server with multiple toolkits
const const server: MCPConfigCreateResponseserver = await const composio: Composio<OpenAIProvider>composio.Composio<OpenAIProvider>.mcp: MCP
Model Context Protocol server management
mcp
.
MCP.create(name: string, mcpConfig: {
    toolkits: (string | {
        toolkit?: string | undefined;
        authConfigId?: string | undefined;
    })[];
    allowedTools?: string[] | undefined;
    manuallyManageConnections?: boolean | undefined;
}): Promise<MCPConfigCreateResponse>
Create a new MCP configuration.
@paramparams - Parameters for creating the MCP configuration@paramparams.authConfig - Array of auth configurations with id and allowed tools@paramparams.options - Configuration options@paramparams.options.name - Unique name for the MCP configuration@paramparams.options.manuallyManageConnections - Whether to use chat-based authentication or manually connect accounts@returnsCreated server details with instance getter@example```typescript const server = await composio.mcpConfig.create("personal-mcp-server", { toolkits: ["github", "slack"], allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"], manuallyManageConnections: false } }); const server = await composio.mcpConfig.create("personal-mcp-server", { toolkits: [{ toolkit: "gmail", authConfigId: "ac_243434343" }], allowedTools: ["GMAIL_FETCH_EMAILS"], manuallyManageConnections: false } }); ```
create
("mcp-config-73840", { // Pick a unique name for your MCP server
toolkits: (string | {
    toolkit?: string | undefined;
    authConfigId?: string | undefined;
})[]
toolkits
: [
{ authConfigId?: string | undefinedauthConfigId: "ac_xyz123", // Your Gmail auth config ID toolkit?: string | undefinedtoolkit: "gmail" }, { authConfigId?: string | undefinedauthConfigId: "ac_abc456", // Your Google Calendar auth config ID toolkit?: string | undefinedtoolkit: "googlecalendar" } ], allowedTools?: string[] | undefinedallowedTools: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL", "GOOGLECALENDAR_EVENTS_LIST"] }); var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Server created: ${const server: MCPConfigCreateResponseserver.id: stringid}`);
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(const server: MCPConfigCreateResponseserver.id: stringid);

Alternative: You can also create and manage MCP configs directly from the Composio dashboard → MCP Configs.

Generate user URLs

Before generating URLs: Users must authenticate with the toolkits configured in your MCP server. See hosted authentication for how to connect user accounts.

Get server URLs for your users to connect:

# Generate server instance for user
instance = composio.mcp.generate(user_id="user-73840", mcp_config_id=server.id) # Use the user ID for which you created the connected account

print(f"MCP Server URL: {instance['url']}")
// Generate server instance for user
const 
const instance: {
    name: string;
    type: "streamable_http";
    id: string;
    userId: string;
    allowedTools: string[];
    url: string;
    authConfigs: string[];
}
instance
= await const composio: Composio<OpenAIProvider>composio.Composio<OpenAIProvider>.mcp: MCP
Model Context Protocol server management
mcp
.
MCP.generate(userId: string, mcpConfigId: string, options?: {
    manuallyManageConnections?: boolean | undefined;
}): Promise<{
    name: string;
    type: "streamable_http";
    id: string;
    userId: string;
    allowedTools: string[];
    url: string;
    authConfigs: string[];
}>
Get server URLs for an existing MCP server. The response is wrapped according to the provider's specifications.
@example```typescript import { Composio } from "@composio/code"; const composio = new Composio(); const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>"); ```@paramuserId external user id from your database for whom you want the server for@parammcpConfigId config id of the MCPConfig for which you want to create a server for@paramoptions additional options@paramoptions.isChatAuth Authenticate the users via chat when they use the MCP Server
generate
("user-73840",
const server: {
    id: string;
}
server
.id: stringid); // Use the user ID for which you created the connected account
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
("MCP Server URL:",
const instance: {
    name: string;
    type: "streamable_http";
    id: string;
    userId: string;
    allowedTools: string[];
    url: string;
    authConfigs: string[];
}
instance
.url: stringurl);

If users haven't authenticated, the MCP server will still generate a URL but tools requiring authentication won't work until the user connects their accounts.

Use with AI providers

Use the MCP server URL with your AI provider:

from openai import OpenAI

# Initialize OpenAI client
client = OpenAI(api_key="your-openai-api-key")

# Use the MCP server URL you generated
mcp_server_url = "https://backend.composio.dev/v3/mcp/YOUR_SERVER_ID?include_composio_helper_actions=true&user_id=YOUR_USER_ID"

# Use MCP with OpenAI Responses API
response = client.responses.create(
    model="gpt-5",
    tools=[
        {
            "type": "mcp",
            "server_label": "composio-server",
            "server_description": "Composio MCP server for Gmail and Calendar integrations",
            "server_url": mcp_server_url,
            "require_approval": "never",
        },
    ],
    input="What meetings do I have tomorrow? Also check if I have any urgent emails",
)

print("OpenAI MCP Response:", response.output_text)
from anthropic import Anthropic

# Initialize Anthropic client
client = Anthropic(api_key="your-anthropic-api-key")

# Use the MCP server URL you generated
mcp_server_url = "https://backend.composio.dev/v3/mcp/YOUR_SERVER_ID?include_composio_helper_actions=true&user_id=YOUR_USER_ID"

# Use MCP with Anthropic (beta feature)
response = client.beta.messages.create(
    model="claude-sonnet-4-5",
    system="You are a helpful assistant with access to various tools through MCP. Use these tools to help the user. Do not ask for confirmation before using the tools.",
    max_tokens=1000,
    messages=[{
        "role": "user",
        "content": "What meetings do I have tomorrow? Also check if I have any urgent emails"
    }],
    mcp_servers=[{
        "type": "url",
        "url": mcp_server_url,
        "name": "composio-gmail-calendar-mcp-server"
    }],
    betas=["mcp-client-2025-04-04"]  # Enable MCP beta
)

print(response.content)
import { class MCPClientMCPClient } from "@mastra/mcp";
import { const openai: OpenAIProvider
Default OpenAI provider instance.
openai
} from "@ai-sdk/openai";
import { class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput>
The Agent class is the foundation for creating AI agents in Mastra. It provides methods for generating responses, streaming interactions, managing memory, and handling voice capabilities.
@example```typescript import { Agent } from '@mastra/core/agent'; import { Memory } from '@mastra/memory'; const agent = new Agent({ id: 'my-agent', name: 'My Agent', instructions: 'You are a helpful assistant', model: 'openai/gpt-5', tools: { calculator: calculatorTool, }, memory: new Memory(), }); ```
Agent
} from "@mastra/core/agent";
// Use the MCP server URL you generated const const MCP_URL: "https://backend.composio.dev/v3/mcp/YOUR_SERVER_ID?include_composio_helper_actions=true&user_id=YOUR_USER_ID"MCP_URL = "https://backend.composio.dev/v3/mcp/YOUR_SERVER_ID?include_composio_helper_actions=true&user_id=YOUR_USER_ID"; export const const client: MCPClientclient = new new MCPClient(args: MCPClientOptions): MCPClientMCPClient({ MCPClientOptions.id?: string | undefinedid: "docs-mcp-client", MCPClientOptions.servers: Record<string, MastraMCPServerDefinition>servers: {
composio: {
    url: URL;
}
composio
: { url: URLurl: new var URL: new (url: string | URL, base?: string | URL) => URL
The **`URL`** interface is used to parse, construct, normalize, and encode URL. [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
URL
(const MCP_URL: "https://backend.composio.dev/v3/mcp/YOUR_SERVER_ID?include_composio_helper_actions=true&user_id=YOUR_USER_ID"MCP_URL) },
} }); export const const agent: Agent<"assistant", Record<string, any>>agent = new new Agent<"assistant", Record<string, any>>(config: AgentConfig<"assistant", Record<string, any>>): Agent<"assistant", Record<string, any>>
Creates a new Agent instance with the specified configuration.
@example```typescript import { Agent } from '@mastra/core/agent'; import { Memory } from '@mastra/memory'; const agent = new Agent({ id: 'weatherAgent', name: 'Weather Agent', instructions: 'You help users with weather information', model: 'openai/gpt-5', tools: { getWeather }, memory: new Memory(), maxRetries: 2, }); ```
Agent
({
AgentConfig<"assistant", Record<string, any>>.id: "assistant"
Identifier for the agent.
id
: "assistant",
AgentConfig<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput>.name: string
Unique identifier for the agent.
name
: "Assistant",
AgentConfig<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput>.description?: string | undefined
Description of the agent's purpose and capabilities.
description
: "Helpful AI with MCP tools",
AgentConfig<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput>.instructions: DynamicAgentInstructions
Instructions that guide the agent's behavior. Can be a string, array of strings, system message object, array of system messages, or a function that returns any of these types dynamically.
instructions
: "Use the MCP tools to answer.",
AgentConfig<"assistant", Record<string, any>>.model: MastraModelConfig | DynamicModel | ModelWithRetries[]
The language model used by the agent. Can be provided statically or resolved at runtime.
model
: function openai(modelId: OpenAIResponsesModelId): LanguageModelV3
Default OpenAI provider instance.
openai
("gpt-4-turbo"),
AgentConfig<"assistant", Record<string, any>>.tools?: DynamicArgument<Record<string, any>> | undefined
Tools that the agent can access. Can be provided statically or resolved dynamically.
tools
: await const client: MCPClientclient.MCPClient.getTools(): Promise<Record<string, any>>getTools()
}); (async () => { const
const res: {
    traceId: string | undefined;
    runId: string;
    suspendPayload: any;
    scoringData?: {
        input: Omit<ScorerRunInputForAgent, "runId">;
        output: ScorerRunOutputForAgent;
    } | undefined;
    text: string;
    usage: LanguageModelUsage;
    steps: LLMStepResult<undefined>[];
    finishReason: string | undefined;
    warnings: LanguageModelV2CallWarning[];
    ... 12 more ...;
    tripwire: StepTripwireData | undefined;
}
res
= await const agent: Agent<"assistant", Record<string, any>>agent.
Agent<"assistant", Record<string, any>>.generate<undefined>(messages: MessageListInput, options?: AgentExecutionOptions<undefined> | undefined): Promise<{
    traceId: string | undefined;
    runId: string;
    suspendPayload: any;
    scoringData?: {
        input: Omit<ScorerRunInputForAgent, "runId">;
        output: ScorerRunOutputForAgent;
    } | undefined;
    text: string;
    usage: LanguageModelUsage;
    ... 15 more ...;
    tripwire: StepTripwireData | undefined;
}>
generate
("What meetings do I have tomorrow? Also check if I have any urgent emails");
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(
const res: {
    traceId: string | undefined;
    runId: string;
    suspendPayload: any;
    scoringData?: {
        input: Omit<ScorerRunInputForAgent, "runId">;
        output: ScorerRunOutputForAgent;
    } | undefined;
    text: string;
    usage: LanguageModelUsage;
    steps: LLMStepResult<undefined>[];
    finishReason: string | undefined;
    warnings: LanguageModelV2CallWarning[];
    ... 12 more ...;
    tripwire: StepTripwireData | undefined;
}
res
.text: stringtext);
})();

Next steps

Need help? Join our Discord or raise an issue on GitHub.