Skip to content

Commit

Permalink
fix: clientSse example, update README.md (#27)
Browse files Browse the repository at this point in the history
* fix: Correct clientSse.ts example
* fix: Correct claude-desktop.png image
  • Loading branch information
jirispilka authored Jan 23, 2025
1 parent 2cd2e66 commit 0449700
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ To configure Claude Desktop to work with the MCP server, follow these steps. For
- Look for the 🔌 icon to confirm that the Exa server is connected.

6. Open the Claude Desktop chat and ask "What Apify Actors I can use?"

![Claude-desktop-with-Actors-MCP-server](https://raw.githubusercontent.com/apify/actors-mcp-server/refs/heads/master/docs/claude-desktop.png)

7. Examples
Expand Down
Binary file modified docs/claude-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions src/examples/clientSse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Connect to the MCP server using SSE transport and call a tool.
* The Actors MCP Server will load default Actors.
*
* !!! NOT WORKING - This example needs to be fixed as it does not work !!!
*/

import path from 'path';
Expand All @@ -15,15 +14,17 @@ import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
import dotenv from 'dotenv';
import { EventSource } from 'eventsource';

const REQUEST_TIMEOUT = 120_000; // 2 minutes
// Resolve dirname equivalent in ES module
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);

dotenv.config({ path: path.resolve(dirname, '../../.env') });

const SERVER_URL = 'https://actors-mcp-server/sse';
const SERVER_URL = 'https://actors-mcp-server.apify.actor/sse';
// We need to change forward slash / to underscore _ in the tool name as Anthropic does not allow forward slashes in the tool name
const SELECTED_TOOL = 'apify_rag-web-browser';
const QUERY = 'web browser for Anthropic';

if (!process.env.APIFY_TOKEN) {
console.error('APIFY_TOKEN is required but not set in the environment variables.');
Expand Down Expand Up @@ -81,10 +82,11 @@ async function main(): Promise<void> {
}

// Call a tool
console.log('Calling actor ...');
console.log(`Calling actor ... ${SELECTED_TOOL}`);
const result = await client.callTool(
{ name: SELECTED_TOOL, arguments: { query: 'web browser for Anthropic' } },
{ name: SELECTED_TOOL, arguments: { query: QUERY } },
CallToolResultSchema,
{ timeout: REQUEST_TIMEOUT },
);
console.log('Tool result:', JSON.stringify(result, null, 2));
} catch (error: unknown) {
Expand Down

0 comments on commit 0449700

Please sign in to comment.