MCP-server

Lad en AI-agent styre Niotio direkte — Claude, ChatGPT-connectors, Cursor, n8n eller din egen agent-runtime — via Model Context Protocol. Samme 35 værktøjer som API'et og CLI'en, samme data, samme regler.

REST API CLI mcp.md

Forbind en klient

Klienter med fjern-MCP (Claude, ChatGPT-connectors, agent-frameworks)

Indtast endpointet og en Bearer-header med dit API-token. Intet andet.

URL:    https://niotio.dk/mcp\nHeader: Authorization: Bearer <API_TOKEN>

Skrivebordsklienter der kun starter stdio-servere

Brug mcp-remote som bro. Samme blok virker i Claude Desktop (claude_desktop_config.json) og i Cursor (~/.cursor/mcp.json).

{
  "mcpServers": {
    "niotio": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://niotio.dk/mcp",
               "--header", "Authorization: Bearer ${NPS_TOKEN}"]
    }
  }
}

Test med curl

curl -s https://niotio.dk/mcp \
  -H "Authorization: Bearer $NPS_TOKEN" -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
       "params":{"name":"campaigns_list","arguments":{"test":true}}}'

initialize er valgfrit: serveren har ingen tilstand og svarer tools/call med det samme. Et værktøjssvar har REST-svaret som teksti content[0].text og som objekt i structuredContent; fejl kommer tilbage med isError: true og REST'ens fejltekst (fx 404: Campaign not found).

Hvad agenten faktisk kan

Et typisk forløb, hvor du kun skriver i naturligt sprog — agenten vælger selv værktøjerne:

Du siger Agenten kalder
»Sæt Q4-målingen op som testkampagne med de 12 kunder.« campaigns_create + campaigns_respondent_add
»Prøv den med realistiske svar, så vi ser scoren.« campaigns_simulate → campaigns_metrics
»Se det efter, og send den så rigtigt.« campaigns_activate + campaigns_send
»Hvem skal vi ringe til?« campaigns_metrics + campaigns_respondents + campaigns_activity
»Tag sagerne fra de sure kunder, og luk dem med et udfald.« cases_list → cases_assign → cases_note_add → cases_status
»Er vi ved at løbe tør for mails i denne måned?« usage_email

Hvert kald er det samme som et API-kald — så det du kan se i revisionsloggen, er også det agenten gjorde. Se hjælpeartiklerne for den praktiske opsætning.

Værktøjer

Hvert værktøj kalder den samme controller-metode som det tilsvarende REST-kald, så adfærd og rettigheder er identiske. Argumenter markeret med påkrævet skal angives.

List the caller's campaigns (real and test). Both types are returned unless `test` filters them. Same data as GET /api/campaigns.

Argument Type Beskrivelse
test boolean true = only test campaigns, false = only real campaigns, omit for both

Fetch one campaign by id. Returns the campaign object, or an error when the caller cannot see it. Same as GET /api/campaigns/{id}.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Create a campaign in DRAFT status. Set `test: true` (or `campaignType: "TEST"`) for a sandbox campaign: test campaigns can be simulated but never send real email. Same as POST /api/campaigns.

Argument Type Beskrivelse
name påkrævet string Campaign name (required)
description string
closeOn string Auto-close timestamp, ISO-8601 local date-time
test boolean Create as a test campaign (default false)
campaignType string Explicit alternative to `test`
autoAnonymizeEnabled boolean
autoAnonymizeDays integer

Update name/description/close date/anonymisation settings. Omitted fields are left unchanged (a name-only update does not reset description, close date or auto-anonymize). The campaign type is fixed at creation: repeating the current type is fine, changing it is rejected. Same as PUT /api/campaigns/{id}.

Argument Type Beskrivelse
id påkrævet integer Campaign id
name påkrævet string
description string
closeOn string ISO-8601 local date-time
test boolean Must match the existing type if sent
campaignType string
autoAnonymizeEnabled boolean
autoAnonymizeDays integer

Move a campaign to the trash (soft delete, restorable for the retention window). Same as DELETE /api/campaigns/{id}.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Restore a trashed campaign. Same as POST /api/campaigns/{id}/restore.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Activate a campaign so it can send surveys. Same as POST /api/campaigns/{id}/activate.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Deactivate (close) a campaign. Same as POST /api/campaigns/{id}/deactivate.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Send the campaign's pending survey emails. Returns sent/failed/blocked/total. A monthly email-quota refusal comes back as an error with `error: monthly_email_limit_reached`. Same as POST /api/campaigns/{id}/send.

Argument Type Beskrivelse
id påkrævet integer Campaign id

NPS score, response counts and promoter/passive/detractor breakdown for one campaign. Same as GET /api/campaigns/{id}/metrics.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Paged respondent list for a campaign, optionally filtered by search text and status. Same as GET /api/campaigns/{id}/respondents.

Argument Type Beskrivelse
id påkrævet integer Campaign id
page integer
size integer
search string Match email or name
status string Respondent status filter

Add one respondent (email) to a campaign. Owner or editor only. Same as POST /api/campaigns/{id}/respondents.

Argument Type Beskrivelse
id påkrævet integer Campaign id
email påkrævet string
name string Defaults to the email
language string Defaults to the request locale

The campaign's audit log (who did what, when). Same as GET /api/campaigns/{id}/activity.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Generate simulated responses on a TEST campaign: `counts` maps rating (0-10) to how many responses to create, `spreadDays` backdates them, `danishPercent` sets how many get Danish comments. Same as POST /api/campaigns/{id}/simulate.

Argument Type Beskrivelse
id påkrævet integer Campaign id
counts object Rating (0-10) to response count
spreadDays integer
danishPercent integer

Remove the simulated data from a test campaign. Same as POST /api/campaigns/{id}/simulate/clear.

Argument Type Beskrivelse
id påkrævet integer Campaign id

Aggregate NPS metrics across the caller's real campaigns that are included in the score. TEST campaigns are excluded, matching the dashboard and GET /api/metrics.

Ingen argumenter.

Survey-email usage this month against the plan allowance and when it resets. Add `include: "campaigns"` for the per-campaign breakdown. Same as GET /api/v1/usage/email.

Argument Type Beskrivelse
include string Include the per-campaign breakdown

Submit a response using the respondent's survey token (from the survey link). Like every MCP tool, this still needs Authorization: Bearer <API_TOKEN> on /mcp — the survey token identifies the respondent, it does not replace the API token. A respondent whose campaign is in the trash is 410 campaign_not_open (kind api, status 410). Same as POST /api/responses.

Argument Type Beskrivelse
token påkrævet string Respondent survey token
rating påkrævet integer
comment string Optional free-text comment

The follow-up case inbox, across every campaign the caller can reach: detractor responses open a case, and someone has to work it. Filter by status (OPEN by default, or a status name, or ALL), by assignee (MINE default, ALL, UNASSIGNED) and by campaign. Same as GET /api/cases.

Argument Type Beskrivelse
status string OPEN (default), NEW, IN_PROGRESS, RESOLVED, NOT_POSSIBLE or ALL
assignee string Defaults to MINE
campaignId integer Narrow to one campaign
overdue boolean Only cases past their SLA due date

Open / overdue / mine / unassigned counts for the inbox header. Same as GET /api/cases/counts.

Ingen argumenter.

One case with the respondent, rating, comment, assignee, status, outcome and due date. Same as GET /api/cases/{id}.

Argument Type Beskrivelse
id påkrævet integer Case id

The case's internal notes (never shown to the respondent), oldest first. Same as GET /api/cases/{id}/notes.

Argument Type Beskrivelse
id påkrævet integer Case id

Append an internal note to a case (max 2000 characters) — what was agreed with the customer, who you talked to. Same as POST /api/cases/{id}/notes.

Argument Type Beskrivelse
id påkrævet integer Case id
body påkrævet string Note text (required)

Give the case to a user who has access to its campaign (they get notified), or unassign it with `unassign: true`. Same as POST /api/cases/{id}/assign.

Argument Type Beskrivelse
id påkrævet integer Case id
assigneeId integer User who has access to the campaign
unassign boolean Remove the assignee instead

Set the status (NEW, IN_PROGRESS, RESOLVED, NOT_POSSIBLE); closing also records the outcome (RETAINED, LOST, UNKNOWN) and reopening clears the close date. Same as POST /api/cases/{id}/status.

Argument Type Beskrivelse
id påkrævet integer Case id
status påkrævet string
outcome string Only meaningful when closing

The account's comment tag vocabulary with counts, a 30-day trend and a `reliable` flag (false = too little data). Filter with `q` (name contains) and `source` (HUMAN = a person created it, AI = the browser's model created it). Each tag reports its own `source` and an `aiCount` (assignments the model applied), which is how AI tags are told apart. Same as GET /api/comment-tags.

Argument Type Beskrivelse
q string Keep tags whose name contains this text
source string HUMAN = created by a person, AI = created by the browser's model

Create a tag in the account's vocabulary. The name is 1-40 characters and unique per account, case-insensitively; a clash is an error. The colour is a hex value like #0d6efd and defaults to grey. Same as POST /api/comment-tags.

Argument Type Beskrivelse
name påkrævet string Tag name (required)
color string Hex colour, e.g. #0d6efd; defaults to grey

Rename and/or recolour one tag; omitted fields are left unchanged and every existing assignment follows a rename. Same as PUT /api/comment-tags/{id}.

Argument Type Beskrivelse
id påkrævet integer Tag id
name string
color string Hex colour, e.g. #0d6efd

Delete a tag and remove it from every comment that carried it. This is not restorable — confirm with the user first. Same as DELETE /api/comment-tags/{id}.

Argument Type Beskrivelse
id påkrævet integer Tag id

Remove every tag assignment the model applied for this account, then any AI-created tag left with no comments. Human tags and human assignments are untouched. Same as DELETE /api/comment-tags/ai.

Ingen argumenter.

The tags on one comment, each with its `source` (who applied it). Reading needs access to the campaign; a stranger gets 404. Same as GET /api/comments/{responseId}/tags.

Argument Type Beskrivelse
responseId påkrævet integer Comment (response) id

Replace the whole tag set on one comment: `tagIds` is the complete set, so an empty array clears every tag. Needs editor access to the campaign; a viewer or stranger gets 404 and a tag id outside the account is a 404. Same as PUT /api/comments/{responseId}/tags.

Argument Type Beskrivelse
responseId påkrævet integer Comment (response) id
tagIds påkrævet array The complete tag set; [] clears

Add one tag to a comment and keep the tags it already has. Needs editor access; tagging the same tag twice is a no-op. Returns the comment's resulting tags. Same as POST /api/comments/{responseId}/tags/{tagId}.

Argument Type Beskrivelse
responseId påkrævet integer Comment (response) id
tagId påkrævet integer Tag id

Remove one tag from a comment and leave its other tags. Removing a tag the comment does not carry is a no-op. Same as DELETE /api/comments/{responseId}/tags/{tagId}.

Argument Type Beskrivelse
responseId påkrævet integer Comment (response) id
tagId påkrævet integer Tag id

Grænser og sikkerhed

Kald pr. minut 120 pr. API-token. Over grænsen svarer serveren 429 med Retry-After, så en agent kan vente pænt. Svarene bærer også X-RateLimit-Limit, -Remaining og -Reset.
Størrelse Maks. 64 KB pr. forespørgsel og højst 50 beskeder i en batch — ellers svarer serveren 413 / -32600.
Cache Alle svar sendes med Cache-Control: no-store: værktøjssvar indeholder kundedata og må ikke caches af en proxy.
Revisionsspor Hvert værktøjskald logges med tokenets ejer, værktøj, udfald og varighed — argumentværdier logges ikke (de indeholder e-mailadresser og kommentarer). Målinger: mcp.tool.calls og mcp.tool.duration.

Regler der også gælder her