Skip to content

Commit ca69a88

Browse files
committed
Rename APIFY_API_TOKEN to APIFY_TOKEN (env variable at Apify platform is APIFY_TOKE)
1 parent 2d474ce commit ca69a88

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
APIFY_API_TOKEN=
1+
APIFY_TOKEN=
22
# ANTHROPIC_API_KEY is only required when you want to run examples/clientStdioChat.js
33
ANTHROPIC_API_KEY=

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ The Actor runs in [**Standby mode**](https://docs.apify.com/platform/actors/runn
8383
Start server with default Actors. To use the Apify MCP Server with set of default Actors,
8484
send an HTTP GET request with your [Apify API token](https://console.apify.com/settings/integrations) to the following URL.
8585
```
86-
https://mcp-server.apify.actor?token=<APIFY_API_TOKEN>
86+
https://actors-mcp-server.apify.actor?token=<APIFY_TOKEN>
8787
```
8888
It is also possible to start MCP server with a different set of tools by providing a list of Actor names in the `actors` query parameter.
8989
Provide a comma-separated list of Actors in the `actors` query parameter:
9090
```
91-
https://mcp-server.apify.actor?token=<APIFY_API_TOKEN>&actors=junglee/free-amazon-product-scraper,lukaskrivka/google-maps-with-contact-details
91+
https://actors-mcp-server.apify.actor?token=<APIFY_TOKEN>&actors=junglee/free-amazon-product-scraper,lukaskrivka/google-maps-with-contact-details
9292
```
9393
Find list of all available Actors in the [Apify Store](https://apify.com/store).
9494

@@ -104,9 +104,9 @@ In the client settings you need to provide server configuration:
104104
"mcpServers": {
105105
"apify": {
106106
"type": "sse",
107-
"url": "https://mcp-server.apify.actor/sse",
107+
"url": "https://actors-mcp-server.apify.actor/sse",
108108
"env": {
109-
"APIFY_API_TOKEN": "your-apify-api-token"
109+
"APIFY_TOKEN": "your-apify-token"
110110
}
111111
}
112112
}
@@ -116,7 +116,7 @@ Alternatively, you can use simple python [client_see.py](https://github.com/apif
116116

117117
1. Initiate Server-Sent-Events (SSE) by sending a GET request to the following URL:
118118
```
119-
curl https://mcp-server.apify.actor/sse?token=<APIFY_API_TOKEN>
119+
curl https://actors-mcp-server.apify.actor/sse?token=<APIFY_TOKEN>
120120
```
121121
The server will respond with a `sessionId`, which you can use to send messages to the server:
122122
```shell
@@ -126,7 +126,7 @@ Alternatively, you can use simple python [client_see.py](https://github.com/apif
126126
127127
2. Send a message to the server by making a POST request with the `sessionId`:
128128
```shell
129-
curl -X POST "https://mcp-server.apify.actor?token=<APIFY_API_TOKEN>&session_id=a1b" -H "Content-Type: application/json" -d '{
129+
curl -X POST "https://actors-mcp-server.apify.actor?token=<APIFY_TOKEN>&session_id=a1b" -H "Content-Type: application/json" -d '{
130130
"jsonrpc": "2.0",
131131
"id": 1,
132132
"method": "tools/call",
@@ -158,7 +158,7 @@ Alternatively, you can use simple python [client_see.py](https://github.com/apif
158158
- MacOS or Windows
159159
- The latest version of Claude Desktop must be installed (or another MCP client)
160160
- [Node.js](https://nodejs.org/en) (v18 or higher)
161-
- [Apify API Token](https://docs.apify.com/platform/integrations/api#api-token) (`APIFY_API_TOKEN`)
161+
- [Apify API Token](https://docs.apify.com/platform/integrations/api#api-token) (`APIFY_TOKEN`)
162162
163163
### Install
164164
@@ -198,7 +198,7 @@ Configure Claude Desktop to recognize the MCP server.
198198
"/path/to/actor-mcp-server/dist/index.js"
199199
]
200200
"env": {
201-
"APIFY_API_TOKEN": "your-apify-api-token"
201+
"APIFY_TOKEN": "your-apify-token"
202202
}
203203
}
204204
}
@@ -214,7 +214,7 @@ Configure Claude Desktop to recognize the MCP server.
214214
"lukaskrivka/google-maps-with-contact-details,apify/instagram-scraper"
215215
]
216216
"env": {
217-
"APIFY_API_TOKEN": "your-apify-api-token"
217+
"APIFY_TOKEN": "your-apify-token"
218218
}
219219
}
220220
}
@@ -239,7 +239,7 @@ Configure Claude Desktop to recognize the MCP server.
239239
240240
Create environment file `.env` with the following content:
241241
```text
242-
APIFY_API_TOKEN=your-apify-api-token
242+
APIFY_TOKEN=your-apify-token
243243
# ANTHROPIC_API_KEY is only required when you want to run examples/clientStdioChat.js
244244
ANTHROPIC_API_KEY=your-anthropic-api-token
245245
```
@@ -271,7 +271,7 @@ standard input/output (stdio):
271271

272272
Create environment file `.env` with the following content:
273273
```text
274-
APIFY_API_TOKEN=your-apify-api-token
274+
APIFY_TOKEN=your-apify-token
275275
# ANTHROPIC_API_KEY is only required when you want to run examples/clientStdioChat.js
276276
ANTHROPIC_API_KEY=your-anthropic-api-token
277277
```
@@ -299,7 +299,7 @@ npm run build
299299
You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command:
300300

301301
```bash
302-
npx @modelcontextprotocol/inspector node /path/to/actor-mcp-server/dist/index.js --env APIFY_API_TOKEN=your-apify-api-token
302+
npx @modelcontextprotocol/inspector node /path/to/actor-mcp-server/dist/index.js --env APIFY_TOKEN=your-apify-token
303303
```
304304

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

src/actorDefinition.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import type { ActorDefinitionWithDesc, Tool } from './types';
1212
* @returns {Promise<ActorDefinitionWithDesc | null>} - The actor definition with description or null if not found.
1313
*/
1414
async function fetchActorDefinition(actorFullName: string): Promise<ActorDefinitionWithDesc | null> {
15-
if (!process.env.APIFY_API_TOKEN) {
16-
log.error('APIFY_API_TOKEN is required but not set. Please set it as an environment variable');
15+
if (!process.env.APIFY_TOKEN) {
16+
log.error('APIFY_TOKEN is required but not set. Please set it as an environment variable');
1717
return null;
1818
}
19-
const client = new ApifyClient({ token: process.env.APIFY_API_TOKEN });
19+
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
2020
const actorClient = client.actor(actorFullName);
2121

2222
try {

src/const.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export const defaults = {
1010
};
1111

1212
export const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 1_000;
13-
export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.` +
14-
`There is no reason to call this tool again!`;
13+
export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.`
14+
+ `There is no reason to call this tool again!`;
1515

1616
export enum Routes {
1717
ROOT = '/',

src/examples/clientStdio.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Connect to the MCP server using stdio transport and call a tool.
44
* This script uses a selected tool without LLM involvement.
5-
* You need to provide the path to the MCP server and `APIFY_API_TOKEN` in the `.env` file.
5+
* You need to provide the path to the MCP server and `APIFY_TOKEN` in the `.env` file.
66
* You can choose actors to run in the server, for example: `apify/rag-web-browser`.
77
*/
88

@@ -26,16 +26,16 @@ const NODE_PATH = execSync(process.platform === 'win32' ? 'where node' : 'which
2626
const TOOLS = 'apify/rag-web-browser,lukaskrivka/google-maps-with-contact-details';
2727
const SELECTED_TOOL = 'apify_rag-web-browser'; // We need to change / to _ in the tool name
2828

29-
if (!process.env.APIFY_API_TOKEN) {
30-
console.error('APIFY_API_TOKEN is required but not set in the environment variables.');
29+
if (!process.env.APIFY_TOKEN) {
30+
console.error('APIFY_TOKEN is required but not set in the environment variables.');
3131
process.exit(1);
3232
}
3333

3434
// Create server parameters for stdio connection
3535
const transport = new StdioClientTransport({
3636
command: NODE_PATH,
3737
args: [SERVER_PATH, '--actors', TOOLS],
38-
env: { APIFY_API_TOKEN: process.env.APIFY_API_TOKEN || '' },
38+
env: { APIFY_TOKEN: process.env.APIFY_TOKEN || '' },
3939
});
4040

4141
// Create a new client instance

src/examples/clientStdioChat.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
*/
1919

2020
import { execSync } from 'child_process';
21+
import path from 'path';
2122
import * as readline from 'readline';
22-
import { fileURLToPath } from "url";
23+
import { fileURLToPath } from 'url';
2324

2425
import { Anthropic } from '@anthropic-ai/sdk';
2526
import type { Message, ToolUseBlock, MessageParam } from '@anthropic-ai/sdk/resources/messages';
2627
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2728
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
2829
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
2930
import dotenv from 'dotenv';
30-
import path from "path";
3131

3232
const filename = fileURLToPath(import.meta.url);
3333
const dirname = path.dirname(filename);
@@ -79,7 +79,7 @@ class MCPClient {
7979
const transport = new StdioClientTransport({
8080
command: NODE_PATH,
8181
args: serverArgs,
82-
env: { APIFY_API_TOKEN: process.env.APIFY_API_TOKEN || '' },
82+
env: { APIFY_TOKEN: process.env.APIFY_TOKEN || '' },
8383
});
8484

8585
await this.client.connect(transport);

src/examples/client_sse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
MCP_SERVER_URL = "https://mcp-server.apify.actor"
2121
ACTORS = "apify/rag-web-browser"
2222

23-
HEADERS = {"Authorization": f"Bearer {os.getenv('APIFY_API_TOKEN')}"}
23+
HEADERS = {"Authorization": f"Bearer {os.getenv('APIFY_TOKEN')}"}
2424

2525
async def run() -> None:
2626

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const app = express();
2323
const mcpServer = new ApifyMcpServer();
2424
let transport: SSEServerTransport;
2525

26-
const HELP_MESSAGE = `Connect to the server with GET request to ${HOST}/sse?token=YOUR-APIFY-API-TOKEN`
27-
+ ` and then send POST requests to ${HOST}/message?token=YOUR-APIFY-API-TOKEN.`;
26+
const HELP_MESSAGE = `Connect to the server with GET request to ${HOST}/sse?token=YOUR-APIFY-TOKEN`
27+
+ ` and then send POST requests to ${HOST}/message?token=YOUR-APIFY-TOKEN.`;
2828

2929
/**
3030
* Process input parameters and update tools

src/server.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
ACTOR_OUTPUT_TRUNCATED_MESSAGE,
1515
defaults,
1616
SERVER_NAME,
17-
SERVER_VERSION
17+
SERVER_VERSION,
1818
} from './const.js';
1919
import { log } from './logger.js';
2020
import type { Tool } from './types';
@@ -46,21 +46,21 @@ export class ApifyMcpServer {
4646
/**
4747
* Calls an Apify actor and retrieves the dataset items.
4848
*
49-
* It requires the `APIFY_API_TOKEN` environment variable to be set.
49+
* It requires the `APIFY_TOKEN` environment variable to be set.
5050
* If the `APIFY_IS_AT_HOME` the dataset items are pushed to the Apify dataset.
5151
*
5252
* @param {string} actorName - The name of the actor to call.
5353
* @param {unknown} input - The input to pass to the actor.
5454
* @returns {Promise<object[]>} - A promise that resolves to an array of dataset items.
55-
* @throws {Error} - Throws an error if the `APIFY_API_TOKEN` is not set
55+
* @throws {Error} - Throws an error if the `APIFY_TOKEN` is not set
5656
*/
5757
public async callActorGetDataset(actorName: string, input: unknown): Promise<object[]> {
58-
if (!process.env.APIFY_API_TOKEN) {
59-
throw new Error('APIFY_API_TOKEN is required but not set. Please set it as an environment variable');
58+
if (!process.env.APIFY_TOKEN) {
59+
throw new Error('APIFY_TOKEN is required but not set. Please set it as an environment variable');
6060
}
6161
try {
6262
log.info(`Calling actor ${actorName} with input: ${JSON.stringify(input)}`);
63-
const client = new ApifyClient({ token: process.env.APIFY_API_TOKEN });
63+
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
6464
const actorClient = client.actor(actorName);
6565

6666
const results = await actorClient.call(input);
@@ -129,20 +129,20 @@ export class ApifyMcpServer {
129129

130130
try {
131131
const items = await this.callActorGetDataset(tool.actorName, args);
132-
const content = items.map(item => {
133-
let text = JSON.stringify(item).slice(0, ACTOR_OUTPUT_MAX_CHARS_PER_ITEM);
132+
const content = items.map((item) => {
133+
const text = JSON.stringify(item).slice(0, ACTOR_OUTPUT_MAX_CHARS_PER_ITEM);
134134
return text.length === ACTOR_OUTPUT_MAX_CHARS_PER_ITEM
135135
? { type: 'text', text: `${text} ... ${ACTOR_OUTPUT_TRUNCATED_MESSAGE}` }
136136
: { type: 'text', text };
137137
});
138-
return { content: content };
139-
138+
return { content };
140139
} catch (error) {
141140
log.error(`Error calling tool: ${error}`);
142141
throw new Error(`Error calling tool: ${error}`);
143142
}
144143
});
145144
}
145+
146146
async connect(transport: Transport): Promise<void> {
147147
await this.server.connect(transport);
148148
}

0 commit comments

Comments
 (0)