DS DevShelfHub Projects · AI tools
Tutorials / MCP / Utilities
MCP Intermediate · 9 min read Page 11 of 23

Utilities — Logging, Progress, Cancellation, Completion

By DevShelfHub

Cross-cutting features that don't belong to any single primitive — but a polished MCP server supports all of them.

Series progress11 / 23
MCP utilities tutorial — logging, progress tokens, cancellation, and completion

Logging

Servers emit notifications/message with a syslog-style LoggingLevel (RFC 5424). Clients filter via logging/setLevel.

LevelWhen to use
debugVerbose diagnostic output.
infoRoutine progress.
noticeNormal but significant.
warningSomething unusual but recoverable.
errorFailure that didn't stop the server.
critical / alert / emergencyEscalating severity.
notifications/message
{
  "jsonrpc": "2.0",
  "method": "notifications/message",
  "params": { "level": "warning", "logger": "auth", "data": "Rate limit close" }
}

Progress

To opt into progress updates, the requester puts a progressToken in params._meta. The receiver then emits notifications/progress carrying the same token.

request with progress token
{
  "method": "tools/call",
  "params": {
    "_meta": { "progressToken": "abc123" },
    "name": "long_operation",
    "arguments": {}
  }
}
progress notification
{
  "method": "notifications/progress",
  "params": { "progressToken": "abc123", "progress": 50, "total": 100, "message": "Indexing..." }
}
  • progress MUST increase monotonically.
  • total is optional — omit if unknown.
  • Each in-flight request needs its own unique token.

Cancellation

Best-effort cancellation: either side sends notifications/cancelled with the request id. Receivers MAY stop work; cancellation is not guaranteed.

{
  "method": "notifications/cancelled",
  "params": { "requestId": 7, "reason": "User pressed Stop" }
}

Argument completion

Clients call completion/complete as the user types arguments for a prompt or resource template. Servers return up to 100 suggestions plus optional total and hasMore.

The _meta field

Reserved on most objects for custom metadata. Use reverse DNS keys (com.example/feature). Prefixes starting with io.modelcontextprotocol/ or mcp/ are reserved. The OpenTelemetry trace keys (traceparent, tracestate, baggage) are special — no prefix required.

Quick summary

  • Logging uses syslog levels — respect logging/setLevel
  • Progress tokens opt in to incremental updates
  • Cancellation is best-effort, not guaranteed
  • Argument completion improves UX with up to 100 suggestions
  • Use reverse DNS keys for custom _meta

MCP Utilities FAQ

What is MCP logging?

MCP servers can send structured log messages to clients via notifications/message. Clients must first call logging/setLevel to subscribe. Log levels follow standard syslog severity (debug, info, warning, error, critical, etc.).

What are MCP progress tokens?

Progress tokens are optional identifiers included in a request's _meta field. While the operation is running, the server sends notifications/progress messages with the same token to report partial progress. Clients use this to show progress bars or status indicators.

How does MCP request cancellation work?

Either side can cancel an in-flight request by sending a notifications/cancelled notification with the request's id. The receiving side should abort the operation and stop sending progress notifications.

What is MCP argument completion?

MCP's completion/complete method lets clients request autocomplete suggestions for tool arguments or prompt arguments. Servers return an array of matching values, enabling IDE-style tab completion in MCP-powered UIs.

What is the _meta field in MCP messages?

The _meta field is a reserved namespace in MCP request and result objects. It carries cross-cutting data like progress tokens without cluttering the main schema. Custom metadata beyond _meta should not be added to standard fields.

Quick jump:API Reference