@apify/actors-mcp-server 0.1.1-beta.0 → 0.1.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/README.md +2 -0
- package/dist/actorDefinition.d.ts +14 -0
- package/dist/actorDefinition.d.ts.map +1 -0
- package/dist/actorDefinition.js +83 -0
- package/dist/actorDefinition.js.map +1 -0
- package/dist/const.d.ts +13 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +19 -0
- package/dist/const.js.map +1 -0
- package/dist/examples/clientSse.d.ts +8 -0
- package/dist/examples/clientSse.d.ts.map +1 -0
- package/dist/examples/clientSse.js +80 -0
- package/dist/examples/clientSse.js.map +1 -0
- package/dist/examples/clientStdio.d.ts +8 -0
- package/dist/examples/clientStdio.d.ts.map +1 -0
- package/dist/examples/clientStdio.js +66 -0
- package/dist/examples/clientStdio.js.map +1 -0
- package/dist/examples/clientStdioChat.d.ts +23 -0
- package/dist/examples/clientStdioChat.d.ts.map +1 -0
- package/dist/examples/clientStdioChat.js +201 -0
- package/dist/examples/clientStdioChat.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/input.d.ts +8 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +14 -0
- package/dist/input.js.map +1 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +4 -0
- package/dist/logger.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +104 -0
- package/dist/main.js.map +1 -0
- package/dist/server.d.ts +31 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +129 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +4 -2
package/LICENSE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 Apify Technologies s.r.o.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Apify Model Context Protocol (MCP) Server
|
|
2
2
|
|
|
3
|
+
[](https://apify.com/apify/actors-mcp-server)
|
|
4
|
+
|
|
3
5
|
Implementation of an MCP server for all [Apify Actors](https://apify.com/store).
|
|
4
6
|
This server enables interaction with one or more Apify Actors that can be defined in the MCP Server configuration.
|
|
5
7
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Tool } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches actor input schemas by actor full names and creates MCP tools.
|
|
4
|
+
*
|
|
5
|
+
* This function retrieves the input schemas for the specified actors and compiles them into MCP tools.
|
|
6
|
+
* It uses the AJV library to validate the input schemas.
|
|
7
|
+
*
|
|
8
|
+
* Tool name can't contain /, so it is replaced with _
|
|
9
|
+
*
|
|
10
|
+
* @param {string[]} actors - An array of actor full names.
|
|
11
|
+
* @returns {Promise<Tool[]>} - A promise that resolves to an array of MCP tools.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getActorsAsTools(actors: string[]): Promise<Tool[]>;
|
|
14
|
+
//# sourceMappingURL=actorDefinition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actorDefinition.d.ts","sourceRoot":"","sources":["../src/actorDefinition.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA2B,IAAI,EAAE,MAAM,SAAS,CAAC;AAkD7D;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAqBxE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
import { ApifyClient } from 'apify-client';
|
|
3
|
+
import { log } from './logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* Get actor input schema by actor name.
|
|
6
|
+
* First, fetch the actor details to get the default build tag and buildId.
|
|
7
|
+
* Then, fetch the build details and return actorName, description, and input schema.
|
|
8
|
+
* @param {string} actorFullName - The full name of the actor.
|
|
9
|
+
* @returns {Promise<ActorDefinitionWithDesc | null>} - The actor definition with description or null if not found.
|
|
10
|
+
*/
|
|
11
|
+
async function fetchActorDefinition(actorFullName) {
|
|
12
|
+
if (!process.env.APIFY_TOKEN) {
|
|
13
|
+
log.error('APIFY_TOKEN is required but not set. Please set it as an environment variable');
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
|
|
17
|
+
const actorClient = client.actor(actorFullName);
|
|
18
|
+
try {
|
|
19
|
+
// Fetch actor details
|
|
20
|
+
const actor = await actorClient.get();
|
|
21
|
+
if (!actor) {
|
|
22
|
+
log.error(`Failed to fetch input schema for actor: ${actorFullName}. Actor not found.`);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// fnesveda: The default build is not necessarily tagged, you can specify any build number as default build.
|
|
26
|
+
// There will be a new API endpoint to fetch a default build.
|
|
27
|
+
// For now, we'll use the tagged build, it will work for 90% of Actors. Later, we can update this.
|
|
28
|
+
const tag = actor.defaultRunOptions?.build || '';
|
|
29
|
+
const buildId = actor.taggedBuilds?.[tag]?.buildId || '';
|
|
30
|
+
if (!buildId) {
|
|
31
|
+
log.error(`Failed to fetch input schema for actor: ${actorFullName}. Build ID not found.`);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
// Fetch build details and return the input schema
|
|
35
|
+
const buildDetails = await client.build(buildId).get();
|
|
36
|
+
if (buildDetails?.actorDefinition) {
|
|
37
|
+
const actorDefinitions = buildDetails?.actorDefinition;
|
|
38
|
+
actorDefinitions.description = actor.description || '';
|
|
39
|
+
actorDefinitions.name = actorFullName;
|
|
40
|
+
return actorDefinitions;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
log.error(`Failed to fetch input schema for actor: ${actorFullName} with error ${error}.`);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fetches actor input schemas by actor full names and creates MCP tools.
|
|
51
|
+
*
|
|
52
|
+
* This function retrieves the input schemas for the specified actors and compiles them into MCP tools.
|
|
53
|
+
* It uses the AJV library to validate the input schemas.
|
|
54
|
+
*
|
|
55
|
+
* Tool name can't contain /, so it is replaced with _
|
|
56
|
+
*
|
|
57
|
+
* @param {string[]} actors - An array of actor full names.
|
|
58
|
+
* @returns {Promise<Tool[]>} - A promise that resolves to an array of MCP tools.
|
|
59
|
+
*/
|
|
60
|
+
export async function getActorsAsTools(actors) {
|
|
61
|
+
// Fetch input schemas in parallel
|
|
62
|
+
const ajv = new Ajv({ coerceTypes: 'array', strict: false });
|
|
63
|
+
const results = await Promise.all(actors.map(fetchActorDefinition));
|
|
64
|
+
const tools = [];
|
|
65
|
+
for (const result of results) {
|
|
66
|
+
if (result) {
|
|
67
|
+
try {
|
|
68
|
+
tools.push({
|
|
69
|
+
name: result.name.replace('/', '_'),
|
|
70
|
+
actorName: result.name,
|
|
71
|
+
description: result.description,
|
|
72
|
+
inputSchema: result.input || {},
|
|
73
|
+
ajvValidate: ajv.compile(result.input || {}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (validationError) {
|
|
77
|
+
log.error(`Failed to compile AJV schema for actor: ${result.name}. Error: ${validationError}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return tools;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=actorDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actorDefinition.js","sourceRoot":"","sources":["../src/actorDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC;;;;;;GAMG;AACH,KAAK,UAAU,oBAAoB,CAAC,aAAqB;IACrD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;QAC3F,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEhD,IAAI,CAAC;QACD,sBAAsB;QACtB,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,GAAG,CAAC,KAAK,CAAC,2CAA2C,aAAa,oBAAoB,CAAC,CAAC;YACxF,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,4GAA4G;QAC5G,6DAA6D;QAC7D,kGAAkG;QAClG,MAAM,GAAG,GAAG,KAAK,CAAC,iBAAiB,EAAE,KAAK,IAAI,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI,EAAE,CAAC;QAEzD,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,GAAG,CAAC,KAAK,CAAC,2CAA2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,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;oBAC/B,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;iBAC/C,CAAC,CAAC;YACP,CAAC;YAAC,OAAO,eAAe,EAAE,CAAC;gBACvB,GAAG,CAAC,KAAK,CAAC,2CAA2C,MAAM,CAAC,IAAI,YAAY,eAAe,EAAE,CAAC,CAAC;YACnG,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
package/dist/const.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const SERVER_NAME = "apify-mcp-server";
|
|
2
|
+
export declare const SERVER_VERSION = "0.1.0";
|
|
3
|
+
export declare const defaults: {
|
|
4
|
+
actors: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 2000;
|
|
7
|
+
export declare const ACTOR_OUTPUT_TRUNCATED_MESSAGE: string;
|
|
8
|
+
export declare enum Routes {
|
|
9
|
+
ROOT = "/",
|
|
10
|
+
SSE = "/sse",
|
|
11
|
+
MESSAGE = "/message"
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=const.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,QAAQ;;CAMpB,CAAC;AAEF,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AACrD,eAAO,MAAM,8BAA8B,QACS,CAAC;AAErD,oBAAY,MAAM;IACd,IAAI,MAAM;IACV,GAAG,SAAS;IACZ,OAAO,aAAa;CACvB"}
|
package/dist/const.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const SERVER_NAME = 'apify-mcp-server';
|
|
2
|
+
export const SERVER_VERSION = '0.1.0';
|
|
3
|
+
export const defaults = {
|
|
4
|
+
actors: [
|
|
5
|
+
'apify/instagram-scraper',
|
|
6
|
+
'apify/rag-web-browser',
|
|
7
|
+
'lukaskrivka/google-maps-with-contact-details',
|
|
8
|
+
],
|
|
9
|
+
};
|
|
10
|
+
export const ACTOR_OUTPUT_MAX_CHARS_PER_ITEM = 2_000;
|
|
11
|
+
export const ACTOR_OUTPUT_TRUNCATED_MESSAGE = `Output was truncated because it will not fit into context.`
|
|
12
|
+
+ ` There is no reason to call this tool again!`;
|
|
13
|
+
export var Routes;
|
|
14
|
+
(function (Routes) {
|
|
15
|
+
Routes["ROOT"] = "/";
|
|
16
|
+
Routes["SSE"] = "/sse";
|
|
17
|
+
Routes["MESSAGE"] = "/message";
|
|
18
|
+
})(Routes || (Routes = {}));
|
|
19
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,MAAM,EAAE;QACJ,yBAAyB;QACzB,uBAAuB;QACvB,8CAA8C;KACjD;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AACrD,MAAM,CAAC,MAAM,8BAA8B,GAAG,4DAA4D;MACpG,8CAA8C,CAAC;AAErD,MAAM,CAAN,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,oBAAU,CAAA;IACV,sBAAY,CAAA;IACZ,8BAAoB,CAAA;AACxB,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientSse.d.ts","sourceRoot":"","sources":["../../src/examples/clientSse.ts"],"names":[],"mappings":"AACA;;;;;GAKG"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
* Connect to the MCP server using SSE transport and call a tool.
|
|
4
|
+
* The Actors MCP Server will load default Actors.
|
|
5
|
+
*
|
|
6
|
+
* !!! This example needs to be fixed as it does not work !!!
|
|
7
|
+
*/
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
+
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
12
|
+
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
13
|
+
import dotenv from 'dotenv';
|
|
14
|
+
import { EventSource } from 'eventsource';
|
|
15
|
+
// Resolve dirname equivalent in ES module
|
|
16
|
+
const filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const dirname = path.dirname(filename);
|
|
18
|
+
dotenv.config({ path: path.resolve(dirname, '../../.env') });
|
|
19
|
+
const SERVER_URL = 'https://actors-mcp-server/sse';
|
|
20
|
+
// We need to change forward slash / to underscore _ in the tool name as Anthropic does not allow forward slashes in the tool name
|
|
21
|
+
const SELECTED_TOOL = 'apify_rag-web-browser';
|
|
22
|
+
if (!process.env.APIFY_TOKEN) {
|
|
23
|
+
console.error('APIFY_TOKEN is required but not set in the environment variables.');
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
if (typeof globalThis.EventSource === 'undefined') {
|
|
27
|
+
globalThis.EventSource = EventSource;
|
|
28
|
+
}
|
|
29
|
+
async function main() {
|
|
30
|
+
const transport = new SSEClientTransport(new URL(SERVER_URL), {
|
|
31
|
+
requestInit: {
|
|
32
|
+
headers: {
|
|
33
|
+
authorization: `Bearer ${process.env.APIFY_TOKEN}`,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
eventSourceInit: {
|
|
37
|
+
// The EventSource package augments EventSourceInit with a "fetch" parameter.
|
|
38
|
+
// You can use this to set additional headers on the outgoing request.
|
|
39
|
+
// Based on this example: https://github.com/modelcontextprotocol/typescript-sdk/issues/118
|
|
40
|
+
async fetch(input, init) {
|
|
41
|
+
const headers = new Headers(init?.headers || {});
|
|
42
|
+
headers.set('authorization', `Bearer ${process.env.APIFY_TOKEN}`);
|
|
43
|
+
return fetch(input, { ...init, headers });
|
|
44
|
+
},
|
|
45
|
+
// We have to cast to "any" to use it, since it's non-standard
|
|
46
|
+
}, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
47
|
+
});
|
|
48
|
+
const client = new Client({ name: 'example-client', version: '1.0.0' }, { capabilities: {} });
|
|
49
|
+
try {
|
|
50
|
+
// Connect to the MCP server
|
|
51
|
+
await client.connect(transport);
|
|
52
|
+
// List available tools
|
|
53
|
+
const tools = await client.listTools();
|
|
54
|
+
console.log('Available tools:', tools);
|
|
55
|
+
if (tools.tools.length === 0) {
|
|
56
|
+
console.log('No tools available');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const selectedTool = tools.tools.find((tool) => tool.name === SELECTED_TOOL);
|
|
60
|
+
if (!selectedTool) {
|
|
61
|
+
console.error(`The specified tool: ${selectedTool} is not available. Exiting.`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// Call a tool
|
|
65
|
+
console.log('Calling actor ...');
|
|
66
|
+
const result = await client.callTool({ name: SELECTED_TOOL, arguments: { query: 'web browser for Anthropic' } }, CallToolResultSchema);
|
|
67
|
+
console.log('Tool result:', JSON.stringify(result, null, 2));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error instanceof Error) {
|
|
71
|
+
console.error('Error:', error.message);
|
|
72
|
+
console.error(error.stack);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.error('An unknown error occurred:', error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
await main();
|
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E,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,uBAAuB,YAAY,6BAA6B,CAAC,CAAC;YAChF,OAAO;QACX,CAAC;QAED,cAAc;QACd,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAChC,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,2BAA2B,EAAE,EAAE,EAC1E,oBAAoB,CACvB,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACtB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACvC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;AACL,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connect to the MCP server using stdio transport and call a tool.
|
|
3
|
+
* This script uses a selected tool without LLM involvement.
|
|
4
|
+
* You need to provide the path to the MCP server and `APIFY_TOKEN` in the `.env` file.
|
|
5
|
+
* You can choose actors to run in the server, for example: `apify/rag-web-browser`.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=clientStdio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientStdio.d.ts","sourceRoot":"","sources":["../../src/examples/clientStdio.ts"],"names":[],"mappings":"AACA;;;;;GAKG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
* Connect to the MCP server using stdio transport and call a tool.
|
|
4
|
+
* This script uses a selected tool without LLM involvement.
|
|
5
|
+
* You need to provide the path to the MCP server and `APIFY_TOKEN` in the `.env` file.
|
|
6
|
+
* You can choose actors to run in the server, for example: `apify/rag-web-browser`.
|
|
7
|
+
*/
|
|
8
|
+
import { execSync } from 'child_process';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
12
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
13
|
+
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
14
|
+
import dotenv from 'dotenv';
|
|
15
|
+
// Resolve dirname equivalent in ES module
|
|
16
|
+
const filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const dirname = path.dirname(filename);
|
|
18
|
+
dotenv.config({ path: path.resolve(dirname, '../../.env') });
|
|
19
|
+
const SERVER_PATH = path.resolve(dirname, '../../dist/index.js');
|
|
20
|
+
const NODE_PATH = execSync(process.platform === 'win32' ? 'where node' : 'which node').toString().trim();
|
|
21
|
+
const TOOLS = 'apify/rag-web-browser,lukaskrivka/google-maps-with-contact-details';
|
|
22
|
+
const SELECTED_TOOL = 'apify_rag-web-browser'; // We need to change / to _ in the tool name
|
|
23
|
+
if (!process.env.APIFY_TOKEN) {
|
|
24
|
+
console.error('APIFY_TOKEN is required but not set in the environment variables.');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
// Create server parameters for stdio connection
|
|
28
|
+
const transport = new StdioClientTransport({
|
|
29
|
+
command: NODE_PATH,
|
|
30
|
+
args: [SERVER_PATH, '--actors', TOOLS],
|
|
31
|
+
env: { APIFY_TOKEN: process.env.APIFY_TOKEN || '' },
|
|
32
|
+
});
|
|
33
|
+
// Create a new client instance
|
|
34
|
+
const client = new Client({ name: 'example-client', version: '0.1.0' }, { capabilities: {} });
|
|
35
|
+
// Main function to run the example client
|
|
36
|
+
async function run() {
|
|
37
|
+
try {
|
|
38
|
+
// Connect to the MCP server
|
|
39
|
+
await client.connect(transport);
|
|
40
|
+
// List available tools
|
|
41
|
+
const tools = await client.listTools();
|
|
42
|
+
console.log('Available tools:', tools);
|
|
43
|
+
if (tools.tools.length === 0) {
|
|
44
|
+
console.log('No tools available');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Example: Call the first available tool
|
|
48
|
+
const selectedTool = tools.tools.find((tool) => tool.name === SELECTED_TOOL);
|
|
49
|
+
if (!selectedTool) {
|
|
50
|
+
console.error(`The specified tool: ${selectedTool} is not available. Exiting.`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Call a tool
|
|
54
|
+
console.log('Calling actor ...');
|
|
55
|
+
const result = await client.callTool({ name: SELECTED_TOOL, arguments: { query: 'web browser for Anthropic' } }, CallToolResultSchema);
|
|
56
|
+
console.log('Tool result:', JSON.stringify(result));
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error('Error:', error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
run().catch((error) => {
|
|
63
|
+
console.error('Unhandled error:', error);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=clientStdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientStdio.js","sourceRoot":"","sources":["../../src/examples/clientStdio.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,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ACL,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAClB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a simple chat client that connects to the Model Context Protocol server using the stdio transport.
|
|
3
|
+
* Based on the user input, the client sends a query to the MCP server, retrieves results and processes them.
|
|
4
|
+
*
|
|
5
|
+
* You can expect the following output:
|
|
6
|
+
*
|
|
7
|
+
* MCP Client Started!
|
|
8
|
+
* Type your queries or 'quit|q|exit' to exit.
|
|
9
|
+
* You: Find to articles about AI agent and return URLs
|
|
10
|
+
* [internal] Received response from Claude: [{"type":"text","text":"I'll search for information about AI agents
|
|
11
|
+
* and provide you with a summary."},{"type":"tool_use","id":"tool_01He9TkzQfh2979bbeuxWVqM","name":"search",
|
|
12
|
+
* "input":{"query":"what are AI agents definition capabilities applications","maxResults":2}}]
|
|
13
|
+
* [internal] Calling tool: {"name":"search","arguments":{"query":"what are AI agents definition ...
|
|
14
|
+
* I can help analyze the provided content about AI agents.
|
|
15
|
+
* This appears to be crawled content from AWS and IBM websites explaining what AI agents are.
|
|
16
|
+
* Let me summarize the key points:
|
|
17
|
+
*/
|
|
18
|
+
export type Tool = {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string | undefined;
|
|
21
|
+
input_schema: unknown;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=clientStdioChat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientStdioChat.d.ts","sourceRoot":"","sources":["../../src/examples/clientStdioChat.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AAgCH,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,YAAY,EAAE,OAAO,CAAC;CACzB,CAAA"}
|