Skip to content

Commit 16628d6

Browse files
authored
feat: add MCP Connector resource type (#602)
1 parent 0e14c72 commit 16628d6

10 files changed

Lines changed: 1783 additions & 494 deletions

File tree

packages/input_schema/src/input_schema.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ export { schema as inputSchema };
1919

2020
const { definitions } = schema;
2121

22-
// Because the definitions contain not only the root properties definitions, but also sub-schema definitions
23-
// and utility definitions, we need to filter them out and validate only against the appropriate ones.
24-
// We do this by checking the prefix of the definition title (Utils: or Sub-schema:)
22+
// Because the definitions contain not only the root properties definitions, but also sub-schema definitions,
23+
// utility definitions, and component definitions, we need to filter them out and validate only against the appropriate ones.
24+
// We do this by checking the prefix of the definition title (Utils:, Component:, or Sub-schema:)
2525

2626
const [fieldDefinitions, subFieldDefinitions] = Object
2727
.values<any>(definitions)
2828
.reduce<[any[], any[]]>((acc, definition) => {
29-
if (definition.title.startsWith('Utils:')) {
30-
// skip utility definitions
29+
if (definition.title.startsWith('Utils:') || definition.title.startsWith('Component:')) {
30+
// skip utility and component definitions
3131
return acc;
3232
}
3333

@@ -271,8 +271,7 @@ function validateFieldAgainstSchemaDefinition(
271271
}
272272
// Otherwise we use the other definition.
273273
const definition = matchingDefinitions.filter((item) => !item.properties.enum && !item.properties.resourceType).pop();
274-
if (!definition) throw new Error('Input schema validation failed to find other than "enum property" definition');
275-
274+
if (!definition) throw new Error('Input schema validation failed to find other than "enum" or "resource" definition');
276275
validateAgainstSchemaOrThrow(validator, fieldSchema, enhanceDefinition(definition), `schema.properties.${fieldKey}`);
277276
}
278277

packages/input_schema/src/types.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,41 @@ export type ArrayFieldDefinition = CommonFieldDefinition<unknown[]> & {
7373

7474
export type CommonResourceFieldDefinition<T> = CommonFieldDefinition<T> & {
7575
editor?: 'resourcePicker' | 'hidden';
76+
resourceType: 'dataset' | 'keyValueStore' | 'requestQueue' | 'mcpConnector';
77+
}
78+
79+
type StorageResourceFieldDefinition<T> = CommonResourceFieldDefinition<T> & {
7680
resourceType: 'dataset' | 'keyValueStore' | 'requestQueue';
7781
resourcePermissions?: ('READ' | 'WRITE')[];
7882
}
7983

80-
export type ResourceFieldDefinition = CommonResourceFieldDefinition<string> & {
84+
type McpServerTools = {
85+
required?: readonly string[];
86+
readOnly?: boolean;
87+
destructive?: boolean;
88+
idempotent?: boolean;
89+
openWorld?: boolean;
90+
}
91+
92+
type McpServer = {
93+
url: string;
94+
tools?: McpServerTools;
95+
}
96+
97+
type McpConnectorResourceFieldDefinition<T> = CommonResourceFieldDefinition<T> & {
98+
resourceType: 'mcpConnector';
99+
mcpServers: readonly McpServer[];
100+
}
101+
102+
type AnyResourceFieldDefinition<T> =
103+
| StorageResourceFieldDefinition<T>
104+
| McpConnectorResourceFieldDefinition<T>
105+
106+
export type ResourceFieldDefinition = AnyResourceFieldDefinition<string> & {
81107
type: 'string';
82108
}
83109

84-
export type ResourceArrayFieldDefinition = CommonResourceFieldDefinition<string[]> & {
110+
export type ResourceArrayFieldDefinition = AnyResourceFieldDefinition<string[]> & {
85111
type: 'array';
86112
maxItems?: number;
87113
minItems?: number;

packages/json_schemas/output/actor.ide.json

Lines changed: 312 additions & 134 deletions
Large diffs are not rendered by default.

packages/json_schemas/output/input.ide.json

Lines changed: 312 additions & 134 deletions
Large diffs are not rendered by default.

packages/json_schemas/output/input.json

Lines changed: 312 additions & 134 deletions
Large diffs are not rendered by default.

packages/json_schemas/rules/add-description/input.description-rules.xml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@
5757
format="markdown">
5858
Titles for the `enum` keys described.
5959
</AddDescription>
60-
<AddDescription json-path="/definitions/resourceProperty/properties/resourcePermissions" format="markdown">
61-
The provided documentation for Actor input schema specification does not contain a description for
62-
`resourcePermissions` in the `resourceProperty` section. It is present in the JSON validation schema, indicating
63-
permissions for the resource.
64-
</AddDescription>
65-
<AddDescription json-path="/definitions/resourceArrayProperty/properties/resourcePermissions" format="markdown">
66-
The provided documentation for Actor input schema specification does not contain a description for
67-
`resourcePermissions` in the `resourceArrayProperty` section. It is present in the JSON validation schema,
68-
indicating permissions for the resource array.
69-
</AddDescription>
7060
<AddDescription json-path="/definitions/anyProperty/properties/type" format="markdown">
7161
Allowed type for the input value. Cannot be mixed.
7262
</AddDescription>
@@ -555,7 +545,7 @@
555545
Visual editor used for the input field. Defaults to `resourcePicker`.
556546
</AddDescription>
557547
<AddDescription json-path="/definitions/resourceProperty/properties/resourceType" format="markdown">
558-
Type of Apify Platform resource
548+
Type of Apify resource this field references - a storage resource (`dataset`, `keyValueStore`, `requestQueue`) or an `mcpConnector`.
559549
</AddDescription>
560550
<AddDescription json-path="/definitions/resourceProperty/properties/default" format="markdown">
561551
Default value that will be used when no value is provided.
@@ -612,7 +602,7 @@
612602
Specifies whether the array should contain only unique values.
613603
</AddDescription>
614604
<AddDescription json-path="/definitions/resourceArrayProperty/properties/resourceType" format="markdown">
615-
Type of Apify Platform resource
605+
Type of Apify resource this field references - a storage resource (`dataset`, `keyValueStore`, `requestQueue`) or an `mcpConnector`.
616606
</AddDescription>
617607
<AddDescription json-path="/definitions/resourceArrayProperty/properties/sectionCaption" format="markdown">
618608
If this property is set, then all fields following this field (this field included) will be separated into a
@@ -623,6 +613,21 @@
623613
If the `sectionCaption` property is set, then you can use this property to provide additional description to the
624614
section. The description will be visible right under the caption when the section is open.
625615
</AddDescription>
616+
<AddDescription json-path="/definitions/resourcePermissionsProperty" format="markdown">
617+
Permissions required for the resource. Only applicable when `resourceType` is `dataset`, `keyValueStore`, or `requestQueue`.
618+
</AddDescription>
619+
<AddDescription json-path="/definitions/mcpServersProperty" format="markdown">
620+
Defines which MCP servers this Actor works with. Each entry describes an acceptable server - a connector can be selected for this input only if it matches at least one entry. Required when `resourceType` is `mcpConnector`.
621+
</AddDescription>
622+
<AddDescription json-path="/definitions/mcpServersProperty/items" format="markdown">
623+
An acceptable MCP server profile. A connector matches if the URL of the server it targets matches `url` and it provides the tools described in `tools`.
624+
</AddDescription>
625+
<AddDescription json-path="/definitions/mcpServersProperty/items/properties/url" format="markdown">
626+
URL pattern that connector's targeted MCP server must match. Supports `*` and `?` wildcards. Use `"*"` to accept any server.
627+
</AddDescription>
628+
<AddDescription json-path="/definitions/mcpServersProperty/items/properties/tools" format="markdown">
629+
Defines which tools the Actor needs and gets access to. `required` lists tool name patterns (supports `*` and `?` wildcards) - the connector must authorize at least one matching tool per pattern. Hint booleans further restrict which tools are considered. Only matching tools are exposed to the Actor.
630+
</AddDescription>
626631
<AddDescription json-path="/definitions/anyProperty/properties/title" format="markdown">
627632
Title of the field in UI.
628633
</AddDescription>

0 commit comments

Comments
 (0)