Agentation MCP Server
Agentation MCP (Model Context Protocol) is a Node.js server designed to provide visual feedback to AI coding agents, such as Claude Code. It facilitates a two-way communication channel where a browser toolbar can send web page annotations to the server, and AI agents can consume these annotations as actionable feedback. The server exposes both an HTTP API for browser interaction (e.g., creating sessions, adding annotations) and an MCP interface (via stdio) to AI agents, offering tools to list, retrieve, acknowledge, resolve, and dismiss annotations. It also supports 'hands-free mode' for continuous agent processing via a `watch_annotations` tool. Currently at version 1.2.0, the package primarily focuses on CLI-driven server operation but ships with TypeScript types, implying programmatic integration is possible. Its key differentiator is providing a structured, visual feedback loop specifically for AI agents interacting with web content.
Common errors
-
Error: listen EADDRINUSE: address already in use :::4747
cause The default HTTP server port (4747) is already in use by another process on your system.fixChange the port using the `--port` option for the CLI (e.g., `agentation-mcp server --port 8080`) or by setting the `AGENTATION_PORT` environment variable if running programmatically. -
Command 'claude mcp add agentation' failed or did not register correctly.
cause The integration with the `claude` CLI might not have completed successfully, or the `agentation` tool was not registered with Claude Code.fixRun `npx agentation-mcp doctor` to diagnose setup issues. If the problem persists, try `npx agentation-mcp init` again to re-run the interactive setup wizard, ensuring Claude Code is running and accessible. -
TypeError: (0, import_agentation_mcp.startServer) is not a function
cause This error typically indicates that `startServer` is not a named export from the `agentation-mcp` package, or the module format (ESM/CJS) is being mishandled.fixVerify the exact export names and module structure by inspecting the package's `index.d.ts` or source code. If the package is ESM-only (likely for Node.js 18+), ensure your consuming project is also configured for ESM (e.g., `"type": "module"` in `package.json`). If `startServer` is a default export, use `import startServer from 'agentation-mcp';`.
Warnings
- gotcha The package primarily emphasizes CLI usage via `npx agentation-mcp server`. While it ships TypeScript types, direct programmatic imports and instantiation of the server are not explicitly documented in the README, requiring users to infer the API based on common Node.js server patterns.
- breaking The package requires Node.js version 18 or greater. Running with older Node.js versions will result in execution errors.
- gotcha The MCP server uses stdio for communication with AI agents. Customizing or proxying this communication requires careful handling of child processes and their standard input/output streams, which is beyond the scope of simple HTTP proxying.
Install
-
npm install agentation-mcp -
yarn add agentation-mcp -
pnpm add agentation-mcp
Imports
- startServer
const { startServer } = require('agentation-mcp');import { startServer } from 'agentation-mcp'; - ServerOptions
import { ServerOptions } from 'agentation-mcp';import { type ServerOptions } from 'agentation-mcp'; - AgentationMcpCli
import { AgentationMcpCli } from 'agentation-mcp';import { runCli } from 'agentation-mcp/cli';
Quickstart
import { startServer, type ServerOptions } from 'agentation-mcp';
const serverOptions: ServerOptions = {
port: parseInt(process.env.AGENTATION_PORT ?? '4747', 10),
mcpOnly: process.env.AGENTATION_MCP_ONLY === 'true',
httpUrl: process.env.AGENTATION_HTTP_URL,
// Add other environment variables for webhooks if needed
// For example, webhookUrl: process.env.AGENTATION_WEBHOOK_URL,
// webhooks: process.env.AGENTATION_WEBHOOKS?.split(','),
};
async function main() {
try {
console.log(`Starting Agentation MCP server with options:`, serverOptions);
const server = await startServer(serverOptions);
console.log(`Agentation MCP HTTP server listening on http://localhost:${serverOptions.port}`);
console.log(`MCP server started (stdio interface for AI agents).`);
// Keep the process alive, or handle graceful shutdown
process.on('SIGINT', async () => {
console.log('Shutting down server...');
await server.stop(); // Assuming a `stop` method exists
process.exit(0);
});
process.on('SIGTERM', async () => {
console.log('Shutting down server...');
await server.stop();
process.exit(0);
});
} catch (error) {
console.error('Failed to start Agentation MCP server:', error);
process.exit(1);
}
}
main();