🎤Micdrop

MCP Tools for a Voice Agent

@micdrop/mcp turns the tools of an MCP server into tools any Micdrop agent can call, whatever its provider.

Installation

Terminal window
npm install @micdrop/mcp @modelcontextprotocol/sdk

Usage

Connect a client of the MCP SDK, then hand its tools to the agent:

import { mcpTools } from '@micdrop/mcp'
import { OpenaiAgent } from '@micdrop/openai'
import { endCallTool } from '@micdrop/server'
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
const client = new Client({ name: 'voice-agent', version: '1.0.0' })
await client.connect(
new StreamableHTTPClientTransport(new URL('https://shop.example.com/mcp'))
)
const agent = new OpenaiAgent({
apiKey: process.env.OPENAI_API_KEY || '',
systemPrompt: 'You help customers with their orders',
tools: [
...(await mcpTools(client, {
exclude: ['delete_account'],
confirm: ['cancel_order'],
})),
endCallTool(),
],
})

One client can serve every call of the process. mcpTools() lists the tools when it is called: call it again to pick up tools the server added since.

The model reads the structured result of a tool when the server sends one, its text otherwise. A result the server marks as an error reaches the model as { error }, so it can tell the user.

Options

OptionTypeDescription
includestring[] | (tool) => booleanKeeps only these tools
excludestring[] | (tool) => booleanLeaves these tools out
confirmstring[] | (tool) => boolean | trueTools that run only once the user agreed on the call
approve({ tool, input }) => booleanCalled before every call, which runs only if it returns true
prefixstringPut before every tool name, to tell several servers apart
timeoutnumberHow long a call can take, in ms

Confirmation before an action

A tool listed in confirm first asks the model to describe what it is about to do and get a yes from the user. The call runs when the model calls it again with the same arguments, after the user answered. See confirmTool().

confirm: true picks every tool the server does not mark as read only or harmless, through the readOnlyHint and destructiveHint annotations of the MCP spec.

approve is the check of your application, a permission of the caller for instance:

await mcpTools(client, {
approve: ({ tool }) => caller.permissions.includes(tool.name),
})

Several servers

Give each server its own prefix, and combine their tools:

tools: [
...(await mcpTools(shopClient, { prefix: 'shop_' })),
...(await mcpTools(crmClient, { prefix: 'crm_' })),
]