1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "openApiSpec": """openapi: 3.0.3
10info:
11 title: Swagger Petstore
12 description: A sample API that uses a petstore as an example
13 version: 1.0.0
14servers:
15 - url: https://petstore3.swagger.io/api/v3
16paths:
17 /pet:
18 post:
19 tags:
20 - pet
21 summary: Add a new pet to the store
22 operationId: addPet
23 requestBody:
24 required: true
25 content:
26 application/json:
27 schema:
28 $ref: '#/components/schemas/Pet'
29 responses:
30 '200':
31 description: Successful operation
32 content:
33 application/json:
34 schema:
35 $ref: '#/components/schemas/Pet'
36 put:
37 tags:
38 - pet
39 summary: Update an existing pet
40 operationId: updatePet
41 requestBody:
42 required: true
43 content:
44 application/json:
45 schema:
46 $ref: '#/components/schemas/Pet'
47 responses:
48 '200':
49 description: Successful operation
50 content:
51 application/json:
52 schema:
53 $ref: '#/components/schemas/Pet'
54 /pet/findByStatus:
55 get:
56 tags:
57 - pet
58 summary: Finds Pets by status
59 operationId: findPetsByStatus
60 parameters:
61 - name: status
62 in: query
63 description: Status values that need to be considered for filter
64 required: true
65 schema:
66 type: array
67 items:
68 type: string
69 enum:
70 - available
71 - pending
72 - sold
73 responses:
74 '200':
75 description: successful operation
76 content:
77 application/json:
78 schema:
79 type: array
80 items:
81 $ref: '#/components/schemas/Pet'
82 /pet/{petId}:
83 get:
84 tags:
85 - pet
86 summary: Find pet by ID
87 operationId: getPetById
88 parameters:
89 - name: petId
90 in: path
91 required: true
92 schema:
93 type: integer
94 format: int64
95 responses:
96 '200':
97 description: successful operation
98 content:
99 application/json:
100 schema:
101 $ref: '#/components/schemas/Pet'
102 delete:
103 tags:
104 - pet
105 summary: Deletes a pet
106 operationId: deletePet
107 parameters:
108 - name: petId
109 in: path
110 required: true
111 schema:
112 type: integer
113 format: int64
114 responses:
115 '200':
116 description: Pet deleted
117components:
118 schemas:
119 Pet:
120 type: object
121 required:
122 - name
123 properties:
124 id:
125 type: integer
126 format: int64
127 nullable: true
128 name:
129 type: string
130 example: doggie
131 status:
132 type: string
133 enum:
134 - available
135 - pending
136 - sold
137 default: available
138""",
139 "format": "yaml",
140 "projectName": "petstore-mcp",
141}
142
143
144run = client.actor("vamsi-krishna/openapi-to-mcp-server-generator").call(run_input=run_input)
145
146
147print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
148for item in client.dataset(run["defaultDatasetId"]).iterate_items():
149 print(item)
150
151