---
title: "Results & content"
description: "Return strings, objects, images, audio, resource links or full MCP results from Nuxt MCP tools, and see exactly which content blocks each return value produces."
canonical_url: "https://mcp-toolkit.nuxt.dev/1.x/core/tools/results"
---
# Results & content

> Return strings, objects, images, audio, resource links or full MCP results from Nuxt MCP tools, and see exactly which content blocks each return value produces.

A tool handler returns plain JavaScript values, and the module converts them into an MCP `CallToolResult`: a `content` array of blocks (text, image, audio, resource links, embedded resources), plus `structuredContent` when the tool declares an [output schema](https://mcp-toolkit.nuxt.dev/1.x/core/tools/structured-output). Throw to report a failure; see [errors](https://mcp-toolkit.nuxt.dev/1.x/core/tools/errors).

The interactive diagram below shows how each handler outcome maps to the JSON payload sent to the client:

<core-tool-lifecycle>



</core-tool-lifecycle>

## Return values

| Handler returns | Client receives |
| --- | --- |
| `string` | One text block |
| `number` or `boolean` | One text block with the stringified value |
| Plain object or array | One text block with pretty-printed JSON |
| `null` or `undefined` | Empty `content` array (`[]`) |
| A `CallToolResult` (has `content`, `structuredContent`, or `isError`) | That result as is (missing `content` is backfilled when `structuredContent` or `isError` is set) |

```ts [server/mcp/tools/server-time.ts]
import { defineMcpTool } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpTool({
  description: 'Read the server time',
  handler: () => new Date().toISOString(),
})
```

With an `outputSchema`, a plain object is treated as structured data instead: see [structured output](https://mcp-toolkit.nuxt.dev/1.x/core/tools/structured-output).

## Images and audio

Use `imageResult(base64, mimeType)` and `audioResult(base64, mimeType)` to return a single media block:

```ts [server/mcp/tools/pixel.ts]
import { defineMcpTool, imageResult } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpTool({
  description: 'Return a one-pixel PNG',
  handler: () => imageResult(
    'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jRZkAAAAASUVORK5CYII=',
    'image/png',
  ),
})
```

To return multiple blocks—such as a caption and an image—return a `CallToolResult` with a `content` array (wrapped in `toolResult()` if the tool declares `outputSchema`):

```ts
return {
  content: [
    { type: 'text', text: 'Generated chart for Q4 revenue.' },
    { type: 'image', data: chartBase64, mimeType: 'image/png' },
  ],
}
```

## Resource links and embedded resources

A tool can point the client at a [resource](https://mcp-toolkit.nuxt.dev/1.x/core/resources/define-resources) instead of inlining it. A `resource_link` block carries the URI and a name; the client reads it with `resources/read` when it needs the content:

```ts [server/mcp/tools/find-guide.ts]
import { z } from 'zod'
import { defineMcpTool } from '@nuxtjs/mcp-toolkit/server'
import { searchGuides } from '../../services/guides'

export default defineMcpTool({
  description: 'Find guides matching a topic and link to each one',
  annotations: { readOnlyHint: true, openWorldHint: false },
  inputSchema: z.object({ topic: z.string().min(1) }),
  handler: async ({ topic }) => {
    const guides = await searchGuides(topic)
    return {
      content: [
        { type: 'text', text: `${guides.length} guides match "${topic}".` },
        ...guides.map(guide => ({
          type: 'resource_link' as const,
          uri: `docs://guides/${guide.slug}`,
          name: guide.slug,
          title: guide.title,
          mimeType: 'text/markdown',
        })),
      ],
    }
  },
})
```

Links keep the result small and let the user open only what matters. Point them at URIs your server actually serves, such as members of a [resource template](https://mcp-toolkit.nuxt.dev/1.x/core/resources/resource-templates).

When the content is short and the model needs it right away, embed it instead with a `resource` block:

```ts
return {
  content: [{
    type: 'resource',
    resource: { uri: 'docs://guides/caching', mimeType: 'text/markdown', text: guideMarkdown },
  }],
}
```

## Content annotations

Every content block accepts optional `annotations`: `audience` (`['user']`, `['assistant']`, or both) tells the client who the block is for, and `priority` (`0` to `1`) how important it is. Clients may use them to hide model-only details from the user or to order blocks. They are hints, never a way to hide data: everything you return reaches the client.

```ts
return {
  content: [
    { type: 'text', text: 'Deployed version 42.', annotations: { audience: ['user'], priority: 1 } },
    { type: 'text', text: rawDeployLog, annotations: { audience: ['assistant'], priority: 0.2 } },
  ],
}
```


## Sitemap

See the full [sitemap](https://mcp-toolkit.nuxt.dev/sitemap.md) for all pages.
