REST API
HTTP REST API for vCon ingestion and operations.
Overview
The vCon MCP Server exposes a RESTful HTTP API alongside the MCP transport layer. This API provides endpoints for vCon CRUD operations, designed for programmatic integration with external systems.
Key Features
HTTP/JSON - Standard REST conventions
API Key Authentication - Secure access with configurable API keys
CORS Support - Configurable cross-origin resource sharing
Plugin Integration - Full lifecycle hooks (beforeCreate, afterCreate, etc.)
Batch Operations - Ingest up to 100 vCons in a single request
Health Checks - Built-in health endpoint for monitoring
Configuration
REST API Variables
REST_API_BASE_PATH
/api/v1
Base path for REST API endpoints
REST_API_ENABLED
true
Enable/disable REST API
Authentication Variables
VCON_API_KEYS
(none)
Comma-separated list of valid API keys
API_KEYS
(none)
Alternative to VCON_API_KEYS
API_KEY_HEADER
x-api-key
Header name for API key
API_AUTH_REQUIRED
true
Set to false to disable authentication
HTTP Transport Variables
The REST API requires HTTP transport mode to be enabled:
MCP_TRANSPORT
stdio
Set to http to enable HTTP server
MCP_HTTP_HOST
127.0.0.1
HTTP host to bind
MCP_HTTP_PORT
3000
HTTP port to listen on
CORS_ORIGIN
*
CORS allowed origins
Example Configuration
Authentication
All REST API endpoints (except /health) require API key authentication.
Request Headers
Authentication Responses
401 Unauthorized - Missing API Key:
401 Unauthorized - Invalid API Key:
503 Service Unavailable - Auth Not Configured:
Note: The
hintfield is only included in non-production environments.
Endpoints
Health Check
Check API and database health status.
Endpoint: GET /api/v1/health
Authentication: Not required
Response (200 OK):
Response (503 Service Unavailable):
Example:
Create vCon
Create/ingest a single vCon.
Endpoint: POST /api/v1/vcons
Authentication: Required
Request Headers:
Request Body:
The request body should be the vCon object directly:
Response (201 Created):
Response (400 Bad Request - Validation Error):
Example:
Batch Create vCons
Ingest multiple vCons in a single request (up to 100).
Endpoint: POST /api/v1/vcons/batch
Authentication: Required
Request Headers:
Request Body:
Array of vCon objects:
Response (201 Created - All Successful):
Response (207 Multi-Status - Partial Success):
Response (400 Bad Request):
Example:
Get vCon
Retrieve a vCon by UUID.
Endpoint: GET /api/v1/vcons/:uuid
Authentication: Required
URL Parameters:
uuid
string
vCon UUID (required)
Response (200 OK):
Response (404 Not Found):
Example:
List vCons
List recent vCons with optional limit.
Endpoint: GET /api/v1/vcons
Authentication: Required
Query Parameters:
limit
number
10
Number of vCons to return (max: 100)
Response (200 OK):
Example:
Delete vCon
Delete a vCon by UUID.
Endpoint: DELETE /api/v1/vcons/:uuid
Authentication: Required
URL Parameters:
uuid
string
vCon UUID (required)
Response (200 OK):
Response (404 Not Found):
Example:
Error Handling
All errors follow a consistent format:
HTTP Status Codes
200
Success
201
Created (new vCon)
207
Multi-Status (batch with partial success)
400
Bad Request (validation error)
401
Unauthorized (authentication failed)
404
Not Found
500
Internal Server Error
503
Service Unavailable
Error Examples
Internal Server Error (500):
Note: In non-production environments, more detailed error messages are included.
Plugin Integration
The REST API integrates with the vCon MCP Server's plugin system. All vCon operations trigger the appropriate lifecycle hooks:
Create vCon
beforeCreate, afterCreate
Get vCon
beforeRead, afterRead
List vCons
beforeSearch, afterSearch
Delete vCon
beforeDelete, afterDelete
This ensures consistent behavior between MCP tools and REST API operations, including:
Privacy filtering
Access control
Audit logging
Data transformation
See the Plugin Development Guide for more information.
Request Logging
All requests are logged with the following information:
Response logging includes duration:
CORS Configuration
The REST API supports CORS with configurable options:
Allowed Methods: GET, POST, PUT, DELETE, OPTIONS
Allowed Headers: Content-Type, x-api-key, Authorization
Configure CORS Origin:
Usage Examples
JavaScript/Node.js
Python
cURL Examples
Comparison: REST API vs MCP Tools
Protocol
HTTP/JSON
MCP (stdio/HTTP)
Auth
API Key
MCP client auth
Best for
External integrations
AI assistants
Operations
CRUD only
Full toolkit (30+ tools)
Search
List only
4 search modes
Batch
Yes (100 max)
No
Streaming
No
Yes (SSE)
Use the REST API for:
External system integrations
Batch ingestion pipelines
Simple CRUD operations
Webhook receivers
Use MCP Tools for:
AI assistant integrations
Advanced search (semantic, hybrid)
Tag management
Database analytics
Schema/examples
Next Steps
See MCP Tools for the full MCP toolkit
See Resources for URI-based access
See Docker Deployment for production setup
See Plugin Development for extending the API
Last updated