or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

auth.mdindex.mdjsonrpc.mdmcp-client.mdmcp-protocol.mdmcp-server.mdmcp-transports.mdmcp-types.mdoauthex.md
tile.json

mcp-types.mddocs/

MCP Types

Core types used throughout the MCP protocol for tools, prompts, resources, and content.

Content Types

Content represents data exchanged in MCP messages. Multiple content types support different media.

Content Interface

Base interface for all content types.

import "github.com/modelcontextprotocol/go-sdk/mcp"

type Content interface {
    MarshalJSON() ([]byte, error)
}

All content types implement this interface: TextContent, ImageContent, AudioContent, ResourceLink, and EmbeddedResource.

TextContent

Represents textual content.

type TextContent struct {
    Text        string
    Meta        Meta
    Annotations *Annotations
}

Example:

content := &mcp.TextContent{
    Text: "Hello, world!",
    Annotations: &mcp.Annotations{
        Priority: 0.8,
    },
}

ImageContent

Contains base64-encoded image data.

type ImageContent struct {
    Meta        Meta
    Annotations *Annotations
    Data        []byte
    MIMEType    string
}

Example:

content := &mcp.ImageContent{
    Data:     imageBytes, // base64-encoded
    MIMEType: "image/png",
}

AudioContent

Contains base64-encoded audio data.

type AudioContent struct {
    Data        []byte
    MIMEType    string
    Meta        Meta
    Annotations *Annotations
}

Example:

content := &mcp.AudioContent{
    Data:     audioBytes, // base64-encoded
    MIMEType: "audio/mpeg",
}

ResourceLink

A link to a resource.

type ResourceLink struct {
    URI         string
    Name        string
    Title       string
    Description string
    MIMEType    string
    Size        *int64
    Meta        Meta
    Annotations *Annotations
}

Example:

size := int64(1024)
content := &mcp.ResourceLink{
    URI:         "file:///path/to/file.txt",
    Name:        "file",
    Description: "A text file",
    MIMEType:    "text/plain",
    Size:        &size,
}

EmbeddedResource

Contains embedded resource data.

type EmbeddedResource struct {
    Resource    *ResourceContents
    Meta        Meta
    Annotations *Annotations
}

ResourceContents

The contents of a specific resource or sub-resource.

type ResourceContents struct {
    URI      string `json:"uri"`
    MIMEType string `json:"mimeType,omitempty"`
    Text     string `json:"text,omitempty"`
    Blob     []byte `json:"blob,omitempty"`
    Meta     Meta   `json:"_meta,omitempty"`
}

Fields:

  • URI: Resource URI (required)
  • MIMEType: MIME type of the content
  • Text: Text content (mutually exclusive with Blob)
  • Blob: Binary content (mutually exclusive with Text)
  • Meta: Reserved metadata

Example:

contents := &mcp.ResourceContents{
    URI:      "file:///data/users.json",
    MIMEType: "application/json",
    Text:     `{"users": []}`,
}

Annotations

Optional annotations for content and resources.

type Annotations struct {
    Audience     []Role  `json:"audience,omitempty"`
    LastModified string  `json:"lastModified,omitempty"`
    Priority     float64 `json:"priority,omitempty"`
}

Fields:

  • Audience: Intended audience (e.g., "user", "assistant")
  • LastModified: ISO 8601 timestamp of last modification
  • Priority: Importance from 0 (least) to 1 (most important)

Role

The sender or recipient in a conversation.

type Role string

Common values: "user", "assistant"

Meta

Additional metadata for requests, responses, and other types.

type Meta map[string]any

Methods:

func (m Meta) GetMeta() map[string]any
func (m Meta) SetMeta(x map[string]any)

Tool Types

Tool

Definition for a tool that clients can call.

type Tool struct {
    Meta         `json:"_meta,omitempty"`
    Annotations  *ToolAnnotations `json:"annotations,omitempty"`
    Description  string           `json:"description,omitempty"`
    InputSchema  any              `json:"inputSchema"`
    Name         string           `json:"name"`
    OutputSchema any              `json:"outputSchema,omitempty"`
    Title        string           `json:"title,omitempty"`
}

Fields:

  • Meta: Reserved metadata field
  • Annotations: Additional tool information and hints
  • Description: Human-readable description
  • InputSchema: JSON Schema object defining expected parameters
  • Name: Programmatic identifier
  • OutputSchema: Optional JSON Schema for tool output
  • Title: Human-readable title for UI contexts

Example:

tool := &mcp.Tool{
    Name:        "calculate",
    Description: "Performs basic arithmetic",
    Title:       "Calculator",
    InputSchema: map[string]any{
        "type": "object",
        "properties": map[string]any{
            "operation": map[string]any{"type": "string"},
            "x":         map[string]any{"type": "number"},
            "y":         map[string]any{"type": "number"},
        },
        "required": []string{"operation", "x", "y"},
    },
}

ToolAnnotations

Additional properties describing a tool to clients (all are hints).

type ToolAnnotations struct {
    DestructiveHint *bool  `json:"destructiveHint,omitempty"`
    IdempotentHint  bool   `json:"idempotentHint,omitempty"`
    OpenWorldHint   *bool  `json:"openWorldHint,omitempty"`
    ReadOnlyHint    bool   `json:"readOnlyHint,omitempty"`
    Title           string `json:"title,omitempty"`
}

Fields:

  • DestructiveHint: If true, tool may perform destructive updates (default: true)
  • IdempotentHint: If true, repeated calls with same args have no additional effect (default: false)
  • OpenWorldHint: If true, tool may interact with external entities (default: true)
  • ReadOnlyHint: If true, tool does not modify its environment (default: false)
  • Title: Human-readable title

Prompt Types

Prompt

A prompt or prompt template that the server offers.

type Prompt struct {
    Meta        `json:"_meta,omitempty"`
    Arguments   []*PromptArgument `json:"arguments,omitempty"`
    Description string            `json:"description,omitempty"`
    Name        string            `json:"name"`
    Title       string            `json:"title,omitempty"`
}

Fields:

  • Meta: Reserved metadata field
  • Arguments: Arguments for templating the prompt
  • Description: What this prompt provides
  • Name: Programmatic identifier
  • Title: Human-readable title for UI contexts

Example:

prompt := &mcp.Prompt{
    Name:        "code-review",
    Description: "Reviews code for quality and style",
    Arguments: []*mcp.PromptArgument{
        {Name: "language", Description: "Programming language", Required: true},
        {Name: "code", Description: "Code to review", Required: true},
    },
}

PromptArgument

Describes an argument that a prompt can accept.

type PromptArgument struct {
    Name        string `json:"name"`
    Title       string `json:"title,omitempty"`
    Description string `json:"description,omitempty"`
    Required    bool   `json:"required,omitempty"`
}

Fields:

  • Name: Programmatic identifier
  • Title: Human-readable title for UI contexts
  • Description: Human-readable description
  • Required: Whether this argument must be provided

PromptMessage

Describes a message returned as part of a prompt.

type PromptMessage struct {
    Content Content `json:"content"`
    Role    Role    `json:"role"`
}

Example:

message := &mcp.PromptMessage{
    Role: "user",
    Content: &mcp.TextContent{
        Text: "Review this code for issues",
    },
}

Resource Types

Resource

A known resource that the server is capable of reading.

type Resource struct {
    Meta        `json:"_meta,omitempty"`
    Annotations *Annotations `json:"annotations,omitempty"`
    Description string       `json:"description,omitempty"`
    MIMEType    string       `json:"mimeType,omitempty"`
    Name        string       `json:"name"`
    Size        int64        `json:"size,omitempty"`
    Title       string       `json:"title,omitempty"`
    URI         string       `json:"uri"`
}

Fields:

  • Meta: Reserved metadata field
  • Annotations: Optional annotations for the client
  • Description: What this resource represents
  • MIMEType: MIME type if known
  • Name: Programmatic identifier
  • Size: Size in bytes
  • Title: Human-readable title for UI contexts
  • URI: URI of this resource

Example:

resource := &mcp.Resource{
    URI:         "file:///data/logs.txt",
    Name:        "logs",
    Description: "Application logs",
    MIMEType:    "text/plain",
    Size:        1024000,
}

ResourceTemplate

A template description for resources available on the server.

type ResourceTemplate struct {
    Meta        `json:"_meta,omitempty"`
    Annotations *Annotations `json:"annotations,omitempty"`
    Description string       `json:"description,omitempty"`
    MIMEType    string       `json:"mimeType,omitempty"`
    Name        string       `json:"name"`
    Title       string       `json:"title,omitempty"`
    URITemplate string       `json:"uriTemplate"`
}

Fields:

  • Meta: Reserved metadata field
  • Annotations: Optional annotations
  • Description: What this template is for
  • MIMEType: MIME type for matching resources
  • Name: Programmatic identifier
  • Title: Human-readable title for UI contexts
  • URITemplate: URI template according to RFC 6570

Example:

template := &mcp.ResourceTemplate{
    URITemplate: "file:///data/{year}/{month}/{day}.log",
    Name:        "daily-logs",
    Description: "Daily application logs",
    MIMEType:    "text/plain",
}

Sampling Types

SamplingMessage

Describes a message issued to or received from an LLM API.

type SamplingMessage struct {
    Content Content `json:"content"`
    Role    Role    `json:"role"`
}

ModelPreferences

Server preferences for model selection during sampling.

type ModelPreferences struct {
    CostPriority         float64      `json:"costPriority,omitempty"`
    Hints                []*ModelHint `json:"hints,omitempty"`
    IntelligencePriority float64      `json:"intelligencePriority,omitempty"`
    SpeedPriority        float64      `json:"speedPriority,omitempty"`
}

Fields:

  • CostPriority: Prioritize cost (0-1)
  • Hints: Optional model selection hints
  • IntelligencePriority: Prioritize intelligence (0-1)
  • SpeedPriority: Prioritize speed (0-1)

ModelHint

Hints to use for model selection.

type ModelHint struct {
    Name string `json:"name,omitempty"`
}

Request and Result Interfaces

Params

Base interface for parameter types.

type Params interface {
    GetMeta() map[string]any
    SetMeta(map[string]any)
}

RequestParams

Interface for request parameter types.

type RequestParams interface {
    GetMeta() map[string]any
    SetMeta(map[string]any)
    GetProgressToken() any
    SetProgressToken(any)
}

Result

Base interface for result types.

type Result interface {
    GetMeta() map[string]any
    SetMeta(map[string]any)
}

Session Types

Session

Interface implemented by ClientSession and ServerSession.

type Session interface {
    ID() string
}

Request

Interface for request types.

type Request interface {
    GetSession() Session
    GetParams() Params
    GetExtra() *RequestExtra
}

RequestExtra

Extra information included in requests from the transport layer.

type RequestExtra struct {
    TokenInfo *auth.TokenInfo
    Header    http.Header
}

Fields:

  • TokenInfo: Bearer token info from OAuth if any
  • Header: HTTP header from request if any

ClientRequest

Generic request type for client requests.

type ClientRequest[P Params] struct {
    Session *ClientSession
    Params  P
}

Methods:

func (r *ClientRequest[P]) GetExtra() *RequestExtra
func (r *ClientRequest[P]) GetParams() Params
func (r *ClientRequest[P]) GetSession() Session

ServerRequest

Generic request type for server requests.

type ServerRequest[P Params] struct {
    Session *ServerSession
    Params  P
    Extra   *RequestExtra
}

Methods:

func (r *ServerRequest[P]) GetExtra() *RequestExtra
func (r *ServerRequest[P]) GetParams() Params
func (r *ServerRequest[P]) GetSession() Session

Implementation Type

Implementation

Describes the name and version of an MCP implementation.

type Implementation struct {
    Name    string `json:"name"`
    Title   string `json:"title,omitempty"`
    Version string `json:"version"`
}

Fields:

  • Name: Programmatic identifier
  • Title: Human-readable title for UI contexts
  • Version: Version string

Logging Types

LoggingLevel

The severity of a log message (maps to syslog severities per RFC-5424).

type LoggingLevel string

Logging Level Constants

const (
    LevelDebug     = slog.LevelDebug
    LevelInfo      = slog.LevelInfo
    LevelNotice    = (slog.LevelInfo + slog.LevelWarn) / 2
    LevelWarning   = slog.LevelWarn
    LevelError     = slog.LevelError
    LevelCritical  = slog.LevelError + 4
    LevelAlert     = slog.LevelError + 8
    LevelEmergency = slog.LevelError + 12
)

Progress Types

ProgressNotificationParams

Parameters for progress notifications.

type ProgressNotificationParams struct {
    Meta          `json:"_meta,omitempty"`
    ProgressToken any     `json:"progressToken"`
    Message       string  `json:"message,omitempty"`
    Progress      float64 `json:"progress"`
    Total         float64 `json:"total,omitempty"`
}

Fields:

  • Meta: Reserved metadata field
  • ProgressToken: Token from the initial request
  • Message: Optional progress description
  • Progress: Progress thus far
  • Total: Total items to process (0 = unknown)

Completion Types

CompleteContext

Additional context for completions.

type CompleteContext struct {
    Arguments map[string]string `json:"arguments,omitempty"`
}

CompleteReference

A completion reference type (ref/prompt or ref/resource).

type CompleteReference struct {
    Type string `json:"type"`
    Name string `json:"name,omitempty"`
    URI  string `json:"uri,omitempty"`
}

Fields:

  • Type: Reference type ("ref/prompt" or "ref/resource")
  • Name: Relevant when Type is "ref/prompt"
  • URI: Relevant when Type is "ref/resource"

CompletionResultDetails

Details of a completion result.

type CompletionResultDetails struct {
    HasMore bool     `json:"hasMore,omitempty"`
    Total   int      `json:"total,omitempty"`
    Values  []string `json:"values"`
}