createServer.md
Create MCP Server
Create a new MCP server instance from a server directory template.
The server will be created in pending status until OAuth credentials are configured. If client_id and client_secret are provided, the server will be set to active status.
OpenAPI
POST /api/servers
openapi: 3.1.0
info:
title: Barndoor Platform API
version: 1.0.0
description: >
REST API for the Barndoor Platform - manage MCP servers, OAuth connections,
and proxy MCP requests.
## Authentication
All endpoints require a JWT Bearer token obtained through Barndoor's
OAuth 2.0 authorization-code flow with PKCE. The SDK handles the OAuth
flow automatically using interactive login.
## MCP Integration
The `/mcp/{mcp_server_name}` endpoints provide streaming proxy access to
third-party MCP servers
(Salesforce, Notion, Slack, etc.) with automatic authentication and session
management.
contact:
name: Barndoor Support
url: https://barndoor.ai
servers:
- url: https://{organization_id}.platform.barndoor.ai
description: Trial (Production)
variables:
organization_id:
description: Your organization identifier
default: your-org
- url: https://{organization_id}.platform.barndoor.ai
description: Enterprise (Production)
variables:
organization_id:
description: Your organization identifier
default: your-org
- url: https://{organization_id}.platform.barndooruat.com
description: Enterprise (Production)
variables:
organization_id:
description: Your organization identifier
default: your-org
- url: https://{organization_id}.platform.barndoordev.com
description: Enterprise (Production)
variables:
organization_id:
description: Your organization identifier
default: your-org
security:
- BearerAuth: []
tags:
- name: Servers
description: Manage MCP server instances
- name: Connections
description: Manage OAuth connections to MCP servers
- name: Policies
description: Manage access control policies for agents and servers
- name: Agents
description: Manage AI agent registrations
- name: MCP Proxy
description: Proxy requests to MCP servers
- name: Identity
description: Retrieve identity information for the authenticated user
paths:
/api/servers:
post:
tags:
- Servers
summary: Create MCP server
description: >
Create a new MCP server instance from a server directory template.
The server will be created in `pending` status until OAuth credentials
are configured.
If `client_id` and `client_secret` are provided, the server will be set
to `active` status.
operationId: createServer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ServerCreateRequest'
responses:
'200':
description: Server created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ServerCreateResponse'
'401':
description: Unauthorized - invalid or missing JWT token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Server directory template not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
components:
schemas:
ServerCreateRequest:
type: object
required:
- name
- mcp_server_directory_id
properties:
name:
type: string
description: Human-readable name for the server
example: My Salesforce Instance
mcp_server_directory_id:
type: string
format: uuid
description: ID of the server directory template to create from
slug:
type: string
description: Optional URL-friendly identifier (auto-generated if not provided)
pattern: ^[a-z0-9-]+$
client_id:
type: string
description: OAuth client ID (for OAuth-enabled servers)
client_secret:
type: string
description: OAuth client secret (for OAuth-enabled servers)
meta:
type: object
description: Additional metadata for the server
additionalProperties: true
ServerCreateResponse:
type: object
properties:
id:
type: string
format: uuid
description: ID of the newly created server
connection_id:
type: string
nullable: true
description: Connection ID if a connection was created
auth_url:
type: string
nullable: true
description: OAuth authorization URL if authentication is required
Error:
type: object
required:
- error
- message
properties:
error:
type: string
description: Error type identifier
example: ServerNotFound
message:
type: string
description: Human-readable error message
example: Server with ID '123' not found
details:
type: object
description: Additional error details
additionalProperties: true
HTTPValidationError:
properties:
detail:
items:
$ref: '#/components/schemas/ValidationError'
type: array
title: Detail
type: object
title: HTTPValidationError
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
type: array
title: Location
msg:
type: string
title: Message
type:
type: string
title: Error Type
input:
title: Input
ctx:
type: object
title: Context
type: object
required:
- loc
- msg
- type
title: ValidationError
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: >
JWT token obtained through Barndoor's OAuth 2.0 authorization-code
flow with PKCE.
The token should be included in the Authorization header:
`Authorization: Bearer <your-jwt-token>`
Use the Barndoor SDK's `loginInteractive()` function to obtain tokens
automatically.