Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
"dependencies": {
"@apify/log": "^2.5.16",
"@modelcontextprotocol/sdk": "github:jirispilka/mcp-typescript-sdk#fix/add-src-dir",
"@modelcontextprotocol/sdk": "^1.10.0",
"ajv": "^8.17.1",
"apify": "^3.4.0",
"apify-client": "^2.12.1",
Expand Down
3 changes: 3 additions & 0 deletions src/actor/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export function createExpressApp(
}
});

// express.json() middleware to parse JSON bodies.
// It must be used before the POST /mcp route but after the GET /sse route :shrug:
app.use(express.json());
app.post(Routes.MCP, async (req: Request, res: Response) => {
log.info('Received MCP request:', req.body);
try {
Expand Down
7 changes: 6 additions & 1 deletion src/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,16 @@ export class ActorsMcpServer {
throw new Error('APIFY_TOKEN is required but not set in the environment variables or passed as a parameter.');
}

// TODO - log errors
// TODO: handle errors better, server.sendLoggingMessage ( )
// TODO - do not raise but return mcp errors
// TODO - if connection is /mcp client will not receive notification on tool change

// Find tool by name or actor full name
const tool = Array.from(this.tools.values())
.find((t) => t.tool.name === name || (t.type === 'actor' && (t.tool as ActorTool).actorFullName === name));
if (!tool) {
// TODO: handle errors better, server.sendLoggingMessage ( )
await this.server.sendLoggingMessage({ level: 'info', data: `Unknown tool $\{name}, available tools ${this.getToolNames()}` });
throw new Error(`Unknown tool: ${name}`);
}
if (!args) {
Expand Down
Loading