BETA
Skip to content

MCP tools

Krafter exposes 37 read-only tools over the Model Context Protocol (MCP), letting AI assistants query data across services using the same API keys you already issue for REST.

Endpoint: POST https://app.krafter.dev/mcp

GET /mcp is reserved by the MCP spec but Krafter does not currently support the Server-Sent Events stream — it returns 405 Method Not Allowed.

Transport

Krafter implements JSON-RPC 2.0 over Streamable HTTP at protocol version 2025-03-26. Each request is a single JSON-RPC message; each response is a single JSON-RPC reply (or 202 for notifications). There is no persistent session.

The server identifies itself as { "name": "krafter", "version": "1.0.0" } in the initialize response.

Supported methods

MethodDescription
initializeNegotiates protocol version and returns server capabilities (tools only).
notifications/initializedClient acknowledgement after initialize. Server replies 202 Accepted.
tools/listReturns the tools the calling API key is authorised for.
tools/callInvokes a tool. Tool result is returned as a JSON-encoded text content block.

Any other method returns JSON-RPC error code -32601 ("Method not found"). Malformed messages return -32600 ("Invalid request").

Tool errors

JSON-RPC codeMeaning
-32001Tool not found
-32002Permission denied (API key lacks the required scope)
-32602Invalid or missing parameters
-32603Internal error (uncaught exception during tool dispatch)

Authentication

Send an API key in the Authorization header — the same Bearer token format used by the REST API:

Authorization: Bearer kr_live_...

Authentication runs through the standard API key pipeline, so MCP requests count toward the per-team rate limit (default bucket — see rate limits) and produce an audit log entry on every call.

Scope filtering

Each tool module enforces a single <service>:read scope. tools/list only returns tools whose scope the caller's API key satisfies; tools/call re-checks the scope before dispatching.

ModuleRequired scope
Analyticsanalytics:read
Croncron:read
Flagsflags:read
Formsforms:read
Logslogs:read
Mailmail:read
Pushpush:read
Webhookswebhooks:read

A wildcard scope (*) grants access to every module. Any other write-level scope (mail:write, flags:write, …) does not imply read access — pair it with the matching :read scope to use the corresponding MCP tools.

Origin validation

POST /mcp validates the Origin header against :krafter, :mcp_allowed_origins (default ["http://localhost:*"]). Mismatched origins return 403 Forbidden. Configure the list in runtime.exs to allow your assistant's host.

Tool inventory

Analytics — analytics:read (7 tools)

ToolDescription
analytics_list_sitesList all analytics sites for your team.
analytics_get_statsPageviews, visitors, visits over a period with optional dimension breakdown.
analytics_realtimeActive visitors in the last 30 minutes.
analytics_top_pagesMost visited pages for a period.
analytics_top_referrersTop traffic sources for a period.
analytics_eventsCustom event counts and revenue.
analytics_goal_conversionsConversion stats for a specific goal.

Cron — cron:read (3 tools)

ToolDescription
cron_list_jobsAll cron jobs for your team with schedules and last-run info.
cron_get_jobDetails for a single cron job by ID.
cron_list_executionsRecent executions for a specific job.

Flags — flags:read (5 tools)

ToolDescription
flags_list_projectsAll feature-flag projects for your team.
flags_list_flagsFlags in a project, optionally filtered by status and tags.
flags_get_flagA single flag by ID, including its evaluation rules.
flags_list_audit_logAudit log entries for your team's flags.
flags_list_experimentsA/B test experiments for a specific flag.

Forms — forms:read (3 tools)

ToolDescription
forms_list_formsAll forms for your team with submission and unread counts.
forms_get_formDetails for a single form by ID.
forms_list_submissionsSubmissions for a form, with spam-status filter and full-text search.

Logs — logs:read (5 tools)

ToolDescription
logs_list_projectsAll log projects with retention and daily-limit settings.
logs_searchSearch entries by level, stream, full-text query, and time range (max 1000).
logs_list_streamsAll streams within a project.
logs_list_alertsAlerts configured for a project.
logs_get_usageToday's ingestion usage (entry count + bytes).

Mail — mail:read (5 tools)

ToolDescription
mail_list_emailsEmails sent by your team, with status filter and search.
mail_get_emailA single email record with its delivery events.
mail_email_statsTotals by status, with optional daily breakdown.
mail_list_domainsSending domains and their verification status.
mail_list_suppressionsSuppressed addresses (bounces, complaints, manual).

Push — push:read (5 tools)

ToolDescription
push_list_appsPush apps with subscriber counts.
push_list_subscribersSubscribers for an app, filtered by platform / status / tags.
push_list_notificationsNotifications for an app, optionally filtered by status.
push_get_notificationA single notification with targeting and delivery stats.
push_daily_statsDaily counters for an app (sent, delivered, clicked, failed, new_subscribers, unsubscribes). The delivered counter is currently always 0 — see Analytics → Response Fields for why.

Webhooks — webhooks:read (4 tools)

ToolDescription
webhooks_list_sourcesWebhook sources for your team.
webhooks_get_sourceDetails for a source including destination count.
webhooks_list_eventsReceived events for a source, with event_type filter.
webhooks_list_destinationsForwarding destinations for a source.

Coverage gaps

The AI Audit service is not yet exposed via MCP. Findings, scans, tasks, and reports must be queried through the REST API at /api/v1/audit/*. There is no audit:read-scoped MCP module.

Write actions across all services (creating emails, toggling flags, scheduling notifications, etc.) are also outside the MCP surface today — MCP is read-only by design.

Built by Krafter Studio