Skip to content

Commit 99bee44

Browse files
committed
fix stdio.js path, get Apify token from env var for stdio and standby Actor use case
1 parent 59a9e0a commit 99bee44

File tree

7 files changed

+11
-7
lines changed

7 files changed

+11
-7
lines changed

.actor/ACTOR.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-
358358

359359
```bash
360360
export APIFY_TOKEN=your-apify-token
361-
npx @modelcontextprotocol/inspector node ./dist/index.js
361+
npx @modelcontextprotocol/inspector node ./dist/stdio.js
362362
```
363363

364364
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-
358358

359359
```bash
360360
export APIFY_TOKEN=your-apify-token
361-
npx @modelcontextprotocol/inspector node ./dist/index.js
361+
npx @modelcontextprotocol/inspector node ./dist/stdio.js
362362
```
363363

364364
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"lint:fix": "eslint . --fix",
6363
"build": "tsc",
6464
"watch": "tsc --watch",
65-
"inspector": "npx @modelcontextprotocol/inspector dist/index.js",
65+
"inspector": "npx @modelcontextprotocol/inspector dist/stdio.js",
6666
"test": "vitest run"
6767
},
6868
"author": "Apify",

src/examples/clientStdio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const filename = fileURLToPath(import.meta.url);
2222
const dirname = path.dirname(filename);
2323

2424
dotenv.config({ path: path.resolve(dirname, '../../.env') });
25-
const SERVER_PATH = path.resolve(dirname, '../../dist/index.js');
25+
const SERVER_PATH = path.resolve(dirname, '../../dist/stdio.js');
2626
const NODE_PATH = execSync(process.platform === 'win32' ? 'where node' : 'which node').toString().trim();
2727

2828
const TOOLS = 'apify/rag-web-browser,lukaskrivka/google-maps-with-contact-details';

src/examples/clientStdioChat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const MAX_TOKENS = 2048; // Maximum tokens for Claude response
4141
// const CLAUDE_MODEL = 'claude-3-5-haiku-20241022'; // a fastest model
4242
const CLAUDE_MODEL = 'claude-3-haiku-20240307'; // a fastest and most compact model for near-instant responsiveness
4343
const DEBUG = true;
44-
const DEBUG_SERVER_PATH = path.resolve(dirname, '../../dist/index.js');
44+
const DEBUG_SERVER_PATH = path.resolve(dirname, '../../dist/stdio.js');
4545

4646
const NODE_PATH = execSync('which node').toString().trim();
4747

src/mcp-server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ export class ApifyMcpServer {
173173
* @throws {Error} - Throws an error if the tool is unknown or arguments are invalid.
174174
*/
175175
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
176-
const { name, arguments: args, apifyToken } = request.params;
176+
const { name, arguments: args } = request.params;
177+
const apifyToken = request.params.apifyToken || process.env.APIFY_TOKEN;
178+
if (!apifyToken) {
179+
throw new Error('APIFY_TOKEN is required but not set in the environment variables or passed as a parameter.');
180+
}
177181

178182
const tool = Array.from(this.tools.values())
179183
.find((t) => t.tool.name === name || (t.type === 'actor' && (t.tool as ActorTool).actorFullName === name));

src/stdio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* --actors - A comma-separated list of actor full names to add to the server.
1010
*
1111
* Example:
12-
* node index.js --actors=apify/google-search-scraper,apify/instagram-scraper
12+
* node stdio.js --actors=apify/google-search-scraper,apify/instagram-scraper
1313
*/
1414

1515
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

0 commit comments

Comments
 (0)