Skip to content

DOCS

MCP and tools

Three layers: builtin agent tools, client-registered frontend tools, and host MCP listed at token mint.

Builtin tools

Names and descriptions from ToolSpec in the agent runtime. search_code and read_code_file are advertised when a workspace index is attached. spawn_tasks fans independent work; it needs a host MCP (or in-memory) backend to resolve subagents.

search_code

Search the local workspace code index with keyword and embedding ranking. Use this before read_code_file.

read_code_file

Read a file from the local workspace index. First call without offset to get the start of the file. If has_more is true, call again with offset.

spawn_tasks

Run multiple independent background tasks in parallel.

search_agent_tools

Semantic search over the agent tool catalog.

Frontend registry.register

Register tools on SvedaToolRegistry before constructing SvedaClient, or pass the registry as tools. Specs go out as stream body clientTools. A tool.call with target: "frontend" runs handler(input, { chatId, toolCallId }). With autoSubmitFrontendToolResults (default true) the session posts results back on the stream.

import { SvedaClient, SvedaToolRegistry } from '@sveda-ai/core'

const tools = new SvedaToolRegistry()
tools.register({
  name: 'get_selection',
  description: 'Return the current UI selection',
  parameters: { type: 'object', properties: {} },
  handler: async (_input, { chatId, toolCallId }) => ({
    chatId,
    toolCallId,
    selection: window.getSelection()?.toString() ?? '',
  }),
})

const client = new SvedaClient({
  endpoints: { stream: '/sveda/stream' },
  headers: { 'x-sveda-embed-token': token },
  tools,
})

Host MCP handshake

Host MCP is not a second client you wire by hand. Pass host_mcp_url and host_mcp_token together on POST /sveda/embed/token. Rules:

  • URL and token must both be present or both absent. Mismatch returns 422 host_mcp_url and host_mcp_token are required together.
  • URL must be http:// or https:// (no whitespace, max 2048 chars).
  • Credentials are stored per visitor_id only when a host API key is configured ( SVEDA_EMBED_HOST_API_KEY / x-sveda-host-key ).
  • On a turn the runtime builds HostMcpClient, calls initialize then tools/list, and executes tools/call with Authorization: Bearer <host_mcp_token>.

Token mint details: embed token. Product: MCP and tools.

curl -s http://127.0.0.1:8787/sveda/embed/token \
  -H 'content-type: application/json' \
  -H 'x-sveda-host-key: $SVEDA_EMBED_HOST_API_KEY' \
  -d '{
    "visitor_id": "visitor-123",
    "host_mcp_url": "https://app.example.com/mcp",
    "host_mcp_token": "host-mcp-secret"
  }'

Catalog ids, not nicknames.

deepseek-v4-flash-responses is the default. Failover walks Flash Anthropic next.

Models