@nightowlsdev/mcp
Adapter/ToolingMastraConnect external MCP servers as Night Owls tools, approval-gated, output-fenced, and engine-wall-safe.
What it does
@nightowlsdev/mcp wraps a Mastra MCPClient and exposes each discovered MCP (Model Context Protocol) tool as a Night Owls SwarmTool, so you grant external MCP tools to agents exactly like any other skill. createMcpConnector takes a map of stdio ({command,args}) or http/SSE ({url}) servers (each with an optional credentialRef) and a SecretResolver; connector.listTools(ctx) returns executable SwarmTools and connector.dispose() tears down the client. It layers four guarantees over a raw MCP client: tools default to needsApproval (origin mcp), untrusted output is wrapped in an <mcp-tool-output untrusted> fence to contain prompt injection, credentials resolve at execute time scoped to the live context, and disposal is explicit. The @mastra/mcp dependency is imported lazily and the Mastra Tool type never reaches the public API, so dist/index.d.ts is @mastra-free, but the package does depend on @mastra/* at runtime. It also exports a CLI plugin manifest so `owl install mcp` can wire it.
Install
pnpm add @nightowlsdev/mcpKey exports
- createMcpConnector
- fenceToolOutput
- nightOwlsPlugin (CLI manifest)
- types: McpConnector, McpConnectorOpts, McpServerDef, McpTool
Usage
import { createMcpConnector } from "@nightowlsdev/mcp";
const connector = createMcpConnector(
{ filesystem: { command: "npx", args: ["-y", "@modelcontextprotocol/server-filesystem", "."] } },
secretResolver,
);
const tools = await connector.listTools(ctx); // MCP tools as Night Owls SwarmTools
// ... grant `tools` to an agent ...
await connector.dispose();