MCP Servers
Configure MCP Workspace endpoints, access tokens and advanced tool settings.
MCP servers expose workspace integrations as tools for AI agents via the Model Context Protocol. New servers use MCP OAuth by default, so each MCP client signs in as the actual end user and receives a token scoped to the server, workspace, and end user.
Bearer-enabled MCP servers also support API-created mcp_ bearer tokens scoped to one end user. Use these when you provision MCP clients for known users and the client cannot complete OAuth. Static bearer tokens are still available for service-style clients, but they are shared server credentials and should not be used when each client needs its own end-user identity.
Servers operate in two modes:
- TOOLS — each integration action is exposed as an individual tool
- CODE — meta-tools let AI agents write code to orchestrate multiple actions
List MCP Servers
/api/v1/mcp/serversList all MCP servers in your organization.
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
workspaceId | string (uuid) | No | Filter servers to one workspace |
limit | integer | No | Number of servers to return, default 50, max 100 |
offset | integer | No | Number of servers to skip for pagination |
includeSuspended | boolean | No | Include suspended servers. Defaults to false |
Response
{
"servers": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"orgId": "550e8400-e29b-41d4-a716-446655440000",
"name": "Sales Tools",
"description": "CRM and email integrations",
"mode": "TOOLS",
"authMode": "oauth",
"endUserAccess": "restricted",
"auth": {
"oauthEnabled": true,
"bearerEnabled": false,
"staticBearerEnabled": false,
"endUserBearerTokensEnabled": false,
"accessTokensEnabled": false
},
"endUserId": null,
"createdBy": "user123",
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"mcpEndpoint": "https://platform.weavz.io/mcp/srv_550e8400-e29b-41d4-a716-446655440000"
}
],
"total": 1
}Example
curl https://platform.weavz.io/api/v1/mcp/servers \
-H "Authorization: Bearer wvz_your_api_key"Create MCP Server
/api/v1/mcp/serversDeprecated compatibility operation. Creating an MCP Workspace already creates its endpoint. Read workspace.mcpServer.id and workspace.mcpServer.mcpEndpoint from that response.
For compatibility with the old two-step setup, this operation may configure a newly prepared, unused endpoint once and return HTTP 201. The endpoint ID stays the same; a newly created static bearer secret is returned once when the requested authentication mode permits it.
After initial configuration or any workspace-bound authorization, the operation returns the existing endpoint unchanged with HTTP 200. Migrated endpoints are treated as already configured. Pass workspaceId and the legacy required name; an already configured endpoint keeps its current name. If explicit mode, authentication, end-user identity, description or settings differ, it returns 409 with code MCP_WORKSPACE_ALREADY_CONFIGURED and the existing endpoint ID. Use Update MCP Server for an intentional change. A second endpoint is never created.
For SDK configuration:
const { server, mcpEndpoint } = await client.mcpWorkspaces.configureMcp(workspaceId, {
mode: 'CODE',
authMode: 'oauth_and_bearer',
})result = client.mcp_workspaces.configure_mcp(
workspace_id, mode="CODE", auth_mode="oauth_and_bearer"
)A workspace has one primary endpoint. Existing additional endpoints remain usable as legacy compatibility connections; their URLs, grants and defaults are preserved.
Get MCP Server
/api/v1/mcp/servers/:idGet server details including its configured tools.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Response
{
"server": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"orgId": "550e8400-e29b-41d4-a716-446655440000",
"name": "Sales Tools",
"mode": "TOOLS",
"endUserId": null,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"mcpEndpoint": "https://platform.weavz.io/mcp/srv_550e8400-e29b-41d4-a716-446655440000"
},
"tools": [
{
"id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890",
"mcpServerId": "550e8400-e29b-41d4-a716-446655440000",
"integrationName": "slack",
"integrationAlias": "slack",
"actionName": "send_channel_message",
"toolType": "ACTION",
"connectionId": "c1d2e3f4-5678-90ab-cdef-1234567890ab",
"displayName": null,
"description": null,
"inputDefaults": null,
"sortOrder": 0
}
]
}Example
curl https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer wvz_your_api_key"Errors
| Status | Code | Description |
|---|---|---|
404 | NOT_FOUND | MCP server not found |
Update MCP Server
This explicitly changes an existing endpoint. allowWorkspaceMembers: true lets authenticated organization members authorize with their own identity, in addition to pre-added end users. It does not share private app accounts. Existing endpoints retain their current setting until an owner changes it.
/api/v1/mcp/servers/:idUpdate server properties.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | Server name |
description | string | No | Server description |
mode | string | No | TOOLS or CODE |
settings | object | No | Server settings. For CODE servers, set settings.codeMode.approvalWaitSeconds from 0 to 60; set settings.mcpApp.enabled to toggle the Weavz MCP App surface. |
authMode | string | No | oauth, bearer, or oauth_and_bearer |
endUserAccess | string | No | restricted or open |
endUserId | string | null | No | The end user's externalId, or null to remove server-level end-user scoping |
Response
{
"server": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Updated Name",
"mode": "CODE",
"authMode": "oauth",
"endUserAccess": "open",
"updatedAt": "2025-01-16T14:00:00.000Z"
}
}Example
curl -X PATCH https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer wvz_your_api_key" \
-H "Content-Type: application/json" \
-d '{"name": "Updated Name", "mode": "CODE", "endUserAccess": "open"}'Errors
| Status | Code | Description |
|---|---|---|
404 | NOT_FOUND | MCP server not found |
Delete MCP Server
Deleting a primary MCP Workspace endpoint alone returns 409 (MCP_WORKSPACE_ENDPOINT_REQUIRED). Delete the workspace explicitly to remove it and its data. This endpoint can still delete an additional legacy endpoint. Deleting a default end user bound to a primary endpoint returns MCP_WORKSPACE_IDENTITY_IN_USE until its default identity is explicitly changed.
/api/v1/mcp/servers/:idDelete an MCP server and all its tools.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Response
{
"deleted": true,
"id": "550e8400-e29b-41d4-a716-446655440000"
}Example
curl -X DELETE https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer wvz_your_api_key"Errors
| Status | Code | Description |
|---|---|---|
404 | NOT_FOUND | MCP server not found |
409 | MCP_WORKSPACE_ENDPOINT_REQUIRED | Delete the MCP Workspace explicitly to remove its primary endpoint. |
Regenerate Token
/api/v1/mcp/servers/:id/regenerate-tokenRegenerate the MCP bearer token. The old token is immediately invalidated. This endpoint is available only when the server's authMode enables static bearer auth.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Response
{
"bearerToken": "mcp_new_token_here...",
"mcpEndpoint": "https://platform.weavz.io/mcp/srv_550e8400-e29b-41d4-a716-446655440000"
}Example
curl -X POST https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/regenerate-token \
-H "Authorization: Bearer wvz_your_api_key"Errors
| Status | Code | Description |
|---|---|---|
404 | NOT_FOUND | MCP server not found |
409 | MCP_BEARER_DISABLED | Static bearer auth is not enabled for this server |
409 | MCP_STATIC_BEARER_INCOMPATIBLE | The workspace has strict per-user integrations and this server is not scoped to one endUserId; create end-user bearer tokens instead |
Create MCP Bearer Token
/api/v1/mcp/servers/:id/access-tokensIssue an mcp_ bearer token scoped to one existing end user. The token is shown only once and can be used as Authorization: Bearer mcp_... until it expires.
The server must be workspace-scoped and use authMode: "bearer" or authMode: "oauth_and_bearer". Each token is scoped to the MCP server, workspace, and selected end user, so multiple clients can use the same bearer-enabled server while resolving actions against different users.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
endUserId | string | Yes | End-user external ID, or internal UUID |
scopes | string[] | No | Defaults to ["mcp:tools"], or ["mcp:tools", "mcp:code"] for Code Mode servers |
expiresIn | number | No | Token lifetime in seconds, from 300 seconds to 90 days. Default: 30 days |
Response (201)
{
"accessToken": "mcp_abc123...",
"bearerToken": "mcp_abc123...",
"token": {
"id": "0c53f814-8dc6-4e98-a680-32bf0a7e4d65",
"tokenPrefix": "mcp_abc123",
"scopes": ["mcp:tools"],
"endUserId": "user_123",
"authMethod": "bearer",
"tokenType": "mcp_bearer",
"expiresAt": "2025-02-14T10:30:00.000Z",
"createdAt": "2025-01-15T10:30:00.000Z"
},
"mcpEndpoint": "https://platform.weavz.io/mcp/srv_550e8400-e29b-41d4-a716-446655440000"
}Example
curl -X POST https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/access-tokens \
-H "Authorization: Bearer wvz_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"endUserId": "user_123",
"scopes": ["mcp:tools"],
"expiresIn": 2592000
}'Errors
| Status | Code | Description |
|---|---|---|
400 | WORKSPACE_REQUIRED | Server is not workspace-scoped |
400 | INVALID_MCP_SCOPES | Requested scopes are not supported by the server mode |
404 | END_USER_NOT_FOUND | End user does not exist in the server workspace |
404 | NOT_FOUND | MCP server not found |
409 | MCP_BEARER_DISABLED | End-user bearer tokens are not enabled for this server |
Create MCP OAuth Token
/api/v1/mcp/servers/:id/oauth-tokensIssue an MCP OAuth access token for an existing end user. The token is shown only once and can be used as Authorization: Bearer mcpo_... until it expires. This is useful when you are provisioning MCP clients programmatically and already know which end user should own the client session.
The server must be workspace-scoped and OAuth-enabled. The token is scoped to the MCP server, workspace, and selected end user.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
endUserId | string | Yes | End-user external ID, or internal UUID |
scopes | string[] | No | Defaults to ["mcp:tools"], or ["mcp:tools", "mcp:code"] for Code Mode servers |
expiresIn | number | No | Token lifetime in seconds, from 300 seconds to 90 days. Default: 30 days |
Response (201)
{
"accessToken": "mcpo_abc123...",
"token": {
"id": "0c53f814-8dc6-4e98-a680-32bf0a7e4d65",
"tokenPrefix": "mcpo_abc123",
"scopes": ["mcp:tools"],
"endUserId": "user_123",
"expiresAt": "2025-02-14T10:30:00.000Z",
"createdAt": "2025-01-15T10:30:00.000Z"
},
"mcpEndpoint": "https://platform.weavz.io/mcp/srv_550e8400-e29b-41d4-a716-446655440000"
}Example
curl -X POST https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/oauth-tokens \
-H "Authorization: Bearer wvz_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"endUserId": "user_123",
"expiresIn": 2592000
}'Errors
| Status | Code | Description |
|---|---|---|
400 | WORKSPACE_REQUIRED | Server is not workspace-scoped |
404 | END_USER_NOT_FOUND | End user does not exist in the server workspace |
404 | NOT_FOUND | MCP server not found |
409 | MCP_OAUTH_DISABLED | MCP OAuth is not enabled for this server |
Add Tool
/api/v1/mcp/servers/:id/toolsAdd an integration action as a tool to the server.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
integrationName | string | Yes | Integration name |
actionName | string | Yes | Action name |
integrationAlias | string | No | Alias for the integration (defaults to integrationName). Must match ^[a-z][a-z0-9_-]*$, max 64 chars |
toolType | string | No | ACTION only (default: ACTION). MCP server tools execute integration actions; triggers are configured through the Triggers API. |
connectionId | string (uuid) | No | Connection to use for this tool. Omit for actions that do not require external authentication |
displayName | string | No | Custom display name |
description | string | No | Custom description |
inputDefaults | object | No | Default input values |
partialIds | string[] | No | Partial IDs or names to assign to this tool. Partials must match the tool integration alias. If omitted, matching default partials can still apply. |
sortOrder | number | No | Sort position (default: 0) |
Integration aliases allow the same integration to appear multiple times on a server under different names (e.g., office_slack and customer_slack), each with its own connection.
Some integrations do not need a connection. Utility and built-in integrations such as storage, kv-store, computer-control, and advanced-code can be added without connectionId. Use a connection only when the action needs authenticated access to an external account or when you want to pin a specific shared account.
Response (201)
{
"tool": {
"id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890",
"mcpServerId": "550e8400-e29b-41d4-a716-446655440000",
"integrationName": "slack",
"integrationAlias": "office_slack",
"actionName": "send_channel_message",
"toolType": "ACTION",
"connectionId": "c1d2e3f4-5678-90ab-cdef-1234567890ab",
"sortOrder": 0
}
}Example
curl -X POST https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/tools \
-H "Authorization: Bearer wvz_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"integrationName": "slack",
"actionName": "send_channel_message",
"integrationAlias": "office_slack",
"connectionId": "c1d2e3f4-5678-90ab-cdef-1234567890ab"
}'Errors
| Status | Code | Description |
|---|---|---|
400 | VALIDATION_ERROR | Missing required fields or invalid alias format |
404 | NOT_FOUND | MCP server not found |
409 | DUPLICATE | Tool already exists on this server |
409 | ALIAS_CONFLICT | Alias is already mapped to a different integration |
Update Tool
/api/v1/mcp/servers/:id/tools/:toolIdUpdate a tool's configuration.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
toolId | string (uuid) | Tool ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
displayName | string | No | Custom display name |
description | string or null | No | Custom description. Set to null to clear it. |
inputDefaults | object | No | Default input values |
connectionId | string (uuid) or null | No | Connection to use. Set to null to clear it. |
sortOrder | number | No | Sort position |
integrationAlias | string | No | Updated alias |
partialIds | string[] | No | Partial IDs or names to assign to this tool. Partials must match the tool integration alias. Send an empty array to clear assigned partials; matching default partials can still apply. |
Response
{
"tool": {
"id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890",
"integrationAlias": "office_slack",
"displayName": "Send Bot Message",
"sortOrder": 1
}
}Example
curl -X PATCH https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/tools/f1e2d3c4-b5a6-7890-abcd-ef1234567890 \
-H "Authorization: Bearer wvz_your_api_key" \
-H "Content-Type: application/json" \
-d '{"displayName": "Send Bot Message", "sortOrder": 1}'Errors
| Status | Code | Description |
|---|---|---|
400 | VALIDATION_ERROR | Invalid fields |
404 | NOT_FOUND | Server or tool not found |
Remove Tool
/api/v1/mcp/servers/:id/tools/:toolIdRemove a tool from the server.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
toolId | string (uuid) | Tool ID |
Response
{
"deleted": true,
"id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890"
}Example
curl -X DELETE https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/tools/f1e2d3c4-b5a6-7890-abcd-ef1234567890 \
-H "Authorization: Bearer wvz_your_api_key"Errors
| Status | Code | Description |
|---|---|---|
404 | NOT_FOUND | Server or tool not found |
Execute Code
/api/v1/mcp/servers/:id/execute-codeExecute code against a Code Mode MCP server, or fetch the result of a previously approved Code Mode Human Gate. Code Mode executions can run for up to 5 minutes. This endpoint is useful for playgrounds, custom harnesses, and SaaS builders that want to test or run Code Mode programmatically.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
code | string | Conditional | JavaScript Code Mode source to execute |
approvalId | string | Conditional | apr_... ID returned by an approval-required Code Mode result. Pass this alone after approval. |
waitForApprovalSeconds | integer | No | Optional override from 0 to 60 seconds for how long an approvalId continuation call waits while approval is still pending. Defaults to the server setting. |
Pass exactly one of code or approvalId.
Response
{
"content": [
{
"type": "text",
"text": "Execution result..."
}
],
"structuredContent": {
"status": "executed",
"output": { "ok": true },
"logs": [],
"actionsExecuted": [],
"durationMs": 650,
"timings": {
"totalExecuteMs": 650,
"sandboxMs": 610,
"browserActionMs": 0,
"steps": []
}
},
"isError": false
}For browser workflows, timings.browserActionMs includes Agent Browser, Agent Browser (Stealth),
Agent Browser AI, Agent Browser (Stealth AI), and Local Browser for Agents action time. timings.steps lists each
integration action called from the Code Mode run, which is useful when debugging a slow workflow from
a custom harness.
When Human Gates pauses the run, the MCP tool result includes structuredContent for clients that support rich output, plus Markdown fallback text in content[0].text. The structured content looks like:
{
"structuredContent": {
"status": "approval_required",
"view": "approval_required",
"title": "Approval required",
"description": "Review this request in Weavz, then continue the tool call.",
"approval": {
"id": "apr_1c7f9d2a0b6e4e219fd9a879f0e8b123",
"approvalUrl": "https://platform.weavz.io/approve/apr_...?token=apr_link_v1_...",
"hostedApprovalUrl": "https://platform.weavz.io/approve/apr_...?token=apr_link_v1_...",
"expiresAt": "2026-05-14T13:00:00.000Z"
},
"links": [
{
"kind": "approval",
"label": "Review approval",
"url": "https://platform.weavz.io/approve/apr_...?token=apr_link_v1_...",
"primary": true
}
],
"continuation": {
"tool": "weavz_execute",
"arguments": { "approvalId": "apr_1c7f9d2a0b6e4e219fd9a879f0e8b123" }
}
}
}For Code Mode, structuredContent.approvals is present when a single run matches multiple approval policies. Retry with any approval ID from the group after a decision; if another policy is still pending, the MCP server returns approval_pending with the next required approval.
After the reviewer approves it, call the same endpoint with { "approvalId": "apr_..." }. Do not submit the original code again; Weavz resumes the stored run and caches the result.
If settings.codeMode.approvalWaitSeconds is enabled, or waitForApprovalSeconds is passed with the approvalId, Weavz waits briefly for the pending Human Gate before returning approval_pending. This does not push into an already completed MCP call; it only holds the active continuation request.
Example
curl -X POST https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/execute-code \
-H "Authorization: Bearer wvz_your_api_key" \
-H "Content-Type: application/json" \
-d '{"code": "const result = await weavz.office_slack.send_channel_message({ channel: \"C123\", text: \"Hello\" }); result;"}'Errors
| Status | Code | Description |
|---|---|---|
400 | INVALID_CODE_EXECUTE_REQUEST | Pass exactly one of code or approvalId, or fix an invalid waitForApprovalSeconds value |
403 | QUOTA_EXCEEDED | Sandbox quota exceeded |
404 | NOT_FOUND | MCP server not found |
Input validation failures inside weavz_execute are returned in the response body as a tool error (isError: true) with a precise message, such as Invalid input for files.write_file: missing required key "path".
Get TypeScript Declarations
/api/v1/mcp/servers/:id/declarations/:aliasGet TypeScript declarations for an alias on a Code Mode server. Returns type definitions for the weavz.* API surface, with hidden/defaulted inputs omitted for that server's tool configuration.
Path Parameters
| Field | Type | Description |
|---|---|---|
id | string | Server ID |
alias | string | Configured integration alias on this MCP server |
Response
{
"declarations": "declare namespace weavz {\n namespace hash {\n function generate_uuid(input: { count?: number }): Promise<{ success: true; uuid: string } | { success: true; uuids: string[]; count: number } | { success: false; error: string }>;\n }\n}"
}Example
curl https://platform.weavz.io/api/v1/mcp/servers/550e8400-e29b-41d4-a716-446655440000/declarations/hash \
-H "Authorization: Bearer wvz_your_api_key"Errors
| Status | Code | Description |
|---|---|---|
404 | NOT_FOUND | Server or integration not found |