Skip to Content

next-workflow-builder

DevKit AI Builder Template DocumentationMarketplace
CTRL K
Demo
CTRL K
  • DevKit 
  • AI Builder Template 
    • Introduction
    • Getting Started
    • Configuration
    • Plugins
      • Overview
      • HTTP Request
      • Condition
      • Loop
      • Merge
      • Database Query
      • Run Workflow
      • Run Workflows in Sequence
      • Switch
    • Creating Plugins
    • API Reference
    • CLI Reference
    • Components
    • Database
    • Authentication
    • Deployment
    • Architecture
    • Contributing
    • MCP Server
  • Marketplace
  • Introduction
  • Getting Started
  • Configuration
  • Plugins
    • Overview
    • HTTP Request
    • Condition
    • Loop
    • Merge
    • Database Query
    • Run Workflow
    • Run Workflows in Sequence
    • Switch
  • Creating Plugins
  • API Reference
  • CLI Reference
  • Components
  • Database
  • Authentication
  • Deployment
  • Architecture
  • Contributing
  • MCP Server

On This Page

  • Enabling the MCP server
  • OAuth discovery routes
  • Database migration
  • Authentication
  • OAuth endpoints
  • MCP endpoint
  • Available tools
  • Connecting Claude Desktop
  • Important notes
  • Connecting Claude Code
Question? Give us feedback Edit this page 
DocumentationMCP Server

MCP Server

The MCP (Model Context Protocol) server lets AI agents programmatically manage workflows — create, update, delete, execute, and discover available actions.

Enabling the MCP server

Add mcp: { enabled: true } to your nextWorkflowBuilder() config:

// next.config.ts import nextWorkflowBuilder from "next-workflow-builder"; const withNWB = nextWorkflowBuilder({ mcp: { enabled: true, loginPage: "/auth/sign-in", // optional, defaults to "/auth/sign-in" }, }); export default withNWB({});

OAuth discovery routes

MCP clients (e.g. Claude Desktop) expect OAuth metadata at /.well-known/oauth-authorization-server and /.well-known/oauth-protected-resource at the root level. Add these two route files to your app:

// app/.well-known/oauth-authorization-server/route.ts export { oAuthDiscoveryHandler as GET } from "next-workflow-builder/api";
// app/.well-known/oauth-protected-resource/route.ts export { oAuthResourceHandler as GET } from "next-workflow-builder/api";

Database migration

The MCP server uses better-auth’s mcp plugin, which creates additional OAuth tables (oauthApplication, oauthAccessToken, oauthConsent). Run your migration command after enabling:

npx drizzle-kit push # or npx nwb migrate

Authentication

The MCP server uses OAuth 2.1 for authentication via better-auth’s built-in MCP plugin. MCP clients authenticate using dynamic client registration (RFC 7591) — no pre-configured client_id or client_secret is needed. The server generates credentials automatically when a client connects for the first time.

When anonymousAuth is enabled (default), requests with existing session cookies (e.g. from a browser) bypass OAuth and use the session directly. Unauthenticated requests receive a 401 with a WWW-Authenticate header pointing to the OAuth discovery metadata, allowing MCP clients to initiate the OAuth flow.

OAuth endpoints

The following endpoints are automatically available:

EndpointDescription
/.well-known/oauth-authorization-serverOAuth authorization server metadata (auto-rewritten)
/.well-known/oauth-protected-resourceOAuth protected resource metadata (auto-rewritten)
/api/auth/mcp/registerDynamic client registration
/api/auth/mcp/authorizeAuthorization endpoint
/api/auth/mcp/tokenToken endpoint

MCP endpoint

All MCP JSON-RPC messages are sent via POST to:

POST /api/workflow-builder/mcp

The endpoint uses Streamable HTTP transport in stateless mode.

Available tools

ToolDescriptionParameters
list_workflowsList user’s workflowslimit?, offset?
get_workflowGet workflow by IDworkflowId
create_workflowCreate a new workflowname, description?, nodes, edges
update_workflowUpdate a workflowworkflowId, name?, description?, nodes?, edges?
delete_workflowDelete a workflowworkflowId
duplicate_workflowDuplicate a workflowworkflowId
execute_workflowExecute a workflowworkflowId, input?
get_execution_statusGet execution status and logsexecutionId
cancel_executionCancel a running executionexecutionId
list_available_actionsList all plugin actions with config fields—
list_integrationsList user’s connected integrations—

Connecting Claude Desktop

To connect Claude Desktop to your MCP server:

  1. Open Claude Desktop settings
  2. Go to the MCP Servers section and add a custom connector
  3. Set the Server URL to your MCP endpoint:
https://your-app.vercel.app/api/workflow-builder/mcp
  1. Leave client_id and client_secret empty — the server uses dynamic client registration and will generate credentials automatically
  2. Click Connect — Claude Desktop will open a browser window for authentication
  3. Sign in on the login page — after signing in, you’ll be redirected back to Claude Desktop with an active connection

Important notes

  • Do not provide a client_id or client_secret in the connector settings. Better-auth manages OAuth clients via dynamic registration. Pre-configured client IDs from other providers (e.g. Vercel OAuth) will not work and will result in an invalid_client error.
  • HTTPS is required for production deployments. For local development, use a tunnel service like ngrok  or loclx  to expose your dev server with a valid certificate.
  • The BETTER_AUTH_URL environment variable must match the URL your MCP client connects to (e.g. your Vercel deployment URL or tunnel URL).

Connecting Claude Code

Add the MCP server to your Claude Code configuration (.claude/settings.json or project-level):

{ "mcpServers": { "workflow-builder": { "url": "https://your-app.vercel.app/api/workflow-builder/mcp" } } }

Claude Code will handle the OAuth authentication flow automatically on first connection.

For local development:

{ "mcpServers": { "workflow-builder": { "url": "http://localhost:3000/api/workflow-builder/mcp" } } }
Last updated on March 12, 2026
Contributing

© 2026 All rights reserved.

Product by David Sanchez