Skip to main content
The Agent MCP Server is a standalone MCP endpoint that lets AI agents programmatically manage SMKRV MCP Studio configuration. Agents can create connections, build tools with Jinja2 transforms, manage global variables, deploy servers, and more — all through the standard MCP protocol.

Quick Start

1. Start Services

docker compose up -d

2. Set Service Token

Add STUDIO_AGENT_SERVICE_TOKEN to your .env file:
STUDIO_AGENT_SERVICE_TOKEN=your-strong-random-secret

3. Create an Agent Token

Open the Studio UI, navigate to Agent Access, click Create Token, enter a name and duration, then copy the generated token.

4. Connect Your MCP Client

{
  "mcpServers": {
    "smkrv-studio": {
      "url": "http://localhost:3000/agent-mcp/",
      "headers": {
        "Authorization": "Bearer smkr_..."
      }
    }
  }
}

Authentication Methods

Temporary Tokens

Best for interactive sessions, testing, and short-lived tasks.
PropertyValue
Duration15 minutes to 7 days
Formatsmkr_<40-char-random>
RevocationInstant via UI or API
Include the token as a Bearer header:
Authorization: Bearer smkr_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789abcd

OAuth2 Client Credentials

Best for automated pipelines, CI/CD, and long-running integrations.
PropertyValue
Idle Timeout15 minutes to 24 hours (sliding window)
Grant Typesclient_credentials, refresh_token
Step 1 — Create client (one-time): Create via the UI (Agent Access > OAuth2 Clients) or API. Save the client_id and client_secret — the secret is shown only once. Step 2 — Exchange credentials for tokens:
curl -X POST http://localhost:3000/agent-mcp/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=smkr_cl_...&client_secret=smkr_cs_..."
Step 3 — Use access token:
{
  "mcpServers": {
    "smkrv-studio": {
      "url": "http://localhost:3000/agent-mcp/",
      "headers": {
        "Authorization": "Bearer smkr_at_..."
      }
    }
  }
}
Step 4 — Refresh when expired:
curl -X POST http://localhost:3000/agent-mcp/oauth/token \
  -d "grant_type=refresh_token&refresh_token=smkr_rt_..."

Comparison

FeatureTemporary TokenOAuth2
SetupSingle stepCreate client + exchange
Max lifetime7 days7 days (idle)
Auto-renewalNoYes (refresh token)
Best forTesting, interactiveCI/CD, automation

MCP Client Configuration

The "type": "http" field is required for Claude Code and most MCP clients. Without it, the client may fail to connect.

Claude Code

Add to ~/.claude/mcp.json or your project’s .mcp.json:
{
  "mcpServers": {
    "smkrv-studio": {
      "type": "http",
      "url": "http://localhost:3000/agent-mcp/mcp",
      "headers": {
        "Authorization": "Bearer smkr_..."
      }
    }
  }
}
Or use the CLI:
claude mcp add --transport http smkrv-studio http://localhost:3000/agent-mcp/mcp

Cursor

Add to .cursor/mcp.json:
{
  "mcpServers": {
    "smkrv-studio": {
      "type": "http",
      "url": "http://localhost:3000/agent-mcp/mcp",
      "headers": {
        "Authorization": "Bearer smkr_..."
      }
    }
  }
}

Production (with SSL)

{
  "mcpServers": {
    "smkrv-studio": {
      "type": "http",
      "url": "https://studio.example.com/agent-mcp/mcp",
      "headers": {
        "Authorization": "Bearer smkr_..."
      }
    }
  }
}

Tool Reference

All 45 tools return structured JSON. Pagination uses skip/limit parameters.

Connections (8 tools)

ToolDescription
list_connectionsList all database connections
get_connectionGet connection details
create_connectionCreate a new connection
update_connectionUpdate connection fields
delete_connectionDelete a connection
test_connectionTest database connectivity
list_tablesList tables in database schema (returns {tables, total})
list_columnsList columns of a table (returns {columns, total})

Tools (8 tools)

ToolDescription
list_toolsList MCP tools (supports compact, fields params)
get_toolGet tool with parameters
create_toolCreate a tool (with optional Jinja2 transform)
create_tools_batchCreate multiple tools in one call (max 50)
update_toolUpdate a tool (including transform template)
delete_toolDelete a tool
duplicate_toolCreate a copy
preview_sqlExecute read-only SQL (with optional Jinja2 transform preview)

Resources (5 tools)

ToolDescription
list_resourcesList MCP resources
get_resourceGet resource details
create_resourceCreate a resource
update_resourceUpdate a resource
delete_resourceDelete a resource

Prompts (5 tools)

ToolDescription
list_promptsList MCP prompts
get_promptGet prompt with template
create_promptCreate a prompt
update_promptUpdate a prompt
delete_promptDelete a prompt

Deploy (3 tools)

ToolDescription
deploy_serverGenerate code and start MCP server
stop_serverStop the running server
get_deploy_statusCheck server status

Export/Import (2 tools)

ToolDescription
export_configExport full configuration as JSON
import_configImport configuration (merge mode, supports dry_run for preview)

History (3 tools)

ToolDescription
list_historyList audit trail entries
get_entity_historyHistory for a specific entity
rollbackRollback to a previous snapshot

Monitoring (3 tools)

ToolDescription
get_metrics_statsPer-tool aggregate metrics
get_metrics_timeseriesTime-series data
get_queue_metricsRedis queue status

Server Config & Global Variables (7 tools)

ToolDescription
get_server_configGet full MCP server configuration
update_server_configUpdate server settings (name, transport, auth, CORS, global variables)
get_global_variablesGet all server-level global variables
set_global_variablesReplace all global variables
update_global_variablesAdd, update, or delete individual variables
get_server_healthCheck deployed MCP server health
get_generated_codeView auto-generated server Python code
Global variables are accessible in all Jinja2 transform templates as {{ "{{ vars.key_name }}" }}. Maximum 100 variables. Names must start with a letter or underscore.

Flow (1 tool)

ToolDescription
get_flow_layoutComplete configuration snapshot

Rate Limiting

Each token is rate-limited to a configurable number of requests per minute (default: 120). Configure via STUDIO_AGENT_RATE_LIMIT env variable or Studio settings.

Activity Log

All agent tool calls are recorded in Redis with timestamp, token prefix, tool name, client IP, and success status. View in the UI on the Agent Access page or via GET /api/v1/agent-activity.

Security Best Practices

  1. Use short-lived tokens for testing (15-30 minutes)
  2. Rotate OAuth2 client secrets periodically
  3. Set a strong service token (STUDIO_AGENT_SERVICE_TOKEN)
  4. Monitor the activity log for unexpected patterns
  5. Use dedicated domains in production for better isolation
  6. Revoke tokens immediately when compromised

Environment Variables

VariableDefaultDescription
STUDIO_AGENT_SERVICE_TOKENShared secret for agent-mcp to backend auth
STUDIO_AGENT_RATE_LIMIT120Requests per minute per token
STUDIO_AGENT_MCP_PORT8090Agent MCP server port
STUDIO_LOG_LEVELINFOLogging level

Troubleshooting

Agent can’t connect

  • Verify the agent-mcp container is running: docker compose ps
  • Check health: curl http://localhost:3000/agent-mcp/health
  • Verify STUDIO_AGENT_SERVICE_TOKEN is set in both backend and agent-mcp environments
  • Check logs: docker compose logs agent-mcp

Tool calls return 401

  • Ensure STUDIO_AGENT_SERVICE_TOKEN matches in both the backend and agent-mcp containers
  • Verify the backend is running and healthy: curl http://localhost:3000/api/health
  • The backend must use get_agent_or_admin (not get_current_admin) for all API endpoints that the agent accesses

Token rejected

  • Confirm the token hasn’t expired
  • Verify it hasn’t been revoked
  • Check rate limits

OAuth flow fails

  • Ensure client_id and client_secret are correct
  • Check the grant_type is client_credentials or refresh_token
  • Verify the OAuth client hasn’t been revoked

See Also

REST API

Full REST API reference for all endpoints

Security

Authentication, token security, and encryption

Deployment

Deploy and connect to the MCP server

SSL/HTTPS Setup

Enable HTTPS for production Agent MCP access

Configuration

Agent MCP environment variables

Troubleshooting

Common issues and debugging tips