Skip to content

Commit ae12574

Browse files
chore: skip spec resource
1 parent f0d8510 commit ae12574

30 files changed

+103
-159
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 21
1+
configured_endpoints: 20
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-ec93b81b2d599edd19449bae3cb40bdb17890908d97cc867e36425a45e491c16.yml
33
openapi_spec_hash: fe8b8fd7782670698fecfe2fcc05f693
4-
config_hash: 50e3bf90ab60d7fbf0d6892930a09fb1
4+
config_hash: 8563083ae1fa5c137476fb1237aa8ea9

api.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,3 @@ Methods:
9696

9797
- <code title="get /v0/orgs/{org}">client.orgs.<a href="./src/resources/orgs.ts">retrieve</a>(org) -> Org</code>
9898
- <code title="get /v0/orgs">client.orgs.<a href="./src/resources/orgs.ts">list</a>() -> OrgListResponse</code>
99-
100-
# Spec
101-
102-
Types:
103-
104-
- <code><a href="./src/resources/spec.ts">SpecRetrieveDecoratedSpecResponse</a></code>
105-
106-
Methods:
107-
108-
- <code title="get /v0/spec/application/{clientId}/{projectName}">client.spec.<a href="./src/resources/spec.ts">retrieveDecoratedSpec</a>(projectName, { ...params }) -> unknown</code>

packages/mcp-server/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,3 @@ The following tools are available in this MCP server.
326326

327327
- `retrieve_orgs` (`read`): Retrieve an organization by name.
328328
- `list_orgs` (`read`): List organizations accessible to the current authentication method.
329-
330-
### Resource `spec`:
331-
332-
- `retrieve_decorated_spec_spec` (`read`):
333-
Retrieve the decorated spec for a given application and project.

packages/mcp-server/src/code-tool-types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ export type WorkerSuccess = {
1111
logLines: string[];
1212
errLines: string[];
1313
};
14-
export type WorkerError = { message: string | undefined };
14+
export type WorkerError = {
15+
message: string | undefined;
16+
logLines: string[];
17+
errLines: string[];
18+
};

packages/mcp-server/src/code-tool-worker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const fuse = new Fuse(
6262
'client.builds.targetOutputs.retrieve',
6363
'client.orgs.list',
6464
'client.orgs.retrieve',
65-
'client.spec.retrieveDecoratedSpec',
6665
],
6766
{ threshold: 1, shouldSort: true },
6867
);
@@ -163,6 +162,8 @@ const fetch = async (req: Request): Promise<Response> => {
163162
{
164163
message:
165164
'The code param is missing. Provide one containing a top-level `run` function. Write code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```',
165+
logLines: [],
166+
errLines: [],
166167
} satisfies WorkerError,
167168
{ status: 400, statusText: 'Code execution error' },
168169
);
@@ -174,6 +175,8 @@ const fetch = async (req: Request): Promise<Response> => {
174175
{
175176
message:
176177
'The code is missing a top-level `run` function. Write code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```',
178+
logLines: [],
179+
errLines: [],
177180
} satisfies WorkerError,
178181
{ status: 400, statusText: 'Code execution error' },
179182
);
@@ -206,6 +209,8 @@ const fetch = async (req: Request): Promise<Response> => {
206209
return Response.json(
207210
{
208211
message: parseError(code, e),
212+
logLines,
213+
errLines,
209214
} satisfies WorkerError,
210215
{ status: 400, statusText: 'Code execution error' },
211216
);

packages/mcp-server/src/code-tool.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,30 @@ export async function codeTool(): Promise<Endpoint> {
133133
content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
134134
};
135135
} else {
136-
const { message } = (await resp.json()) as WorkerError;
136+
const { message, logLines, errLines } = (await resp.json()) as WorkerError;
137+
const messageOutput: ContentBlock | null =
138+
message == null ? null : (
139+
{
140+
type: 'text',
141+
text: message,
142+
}
143+
);
144+
const logOutput: ContentBlock | null =
145+
logLines.length === 0 ?
146+
null
147+
: {
148+
type: 'text',
149+
text: logLines.join('\n'),
150+
};
151+
const errOutput: ContentBlock | null =
152+
errLines.length === 0 ?
153+
null
154+
: {
155+
type: 'text',
156+
text: 'Error output:\n' + errLines.join('\n'),
157+
};
137158
return {
138-
content: message == null ? [] : [{ type: 'text', text: message }],
159+
content: [messageOutput, logOutput, errOutput].filter((block) => block !== null),
139160
isError: true,
140161
};
141162
}

packages/mcp-server/src/tools/builds/create-builds.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
import { Metadata, asTextContentResult } from '@stainless-api/sdk-mcp/tools/types';
3+
import { Metadata, asErrorResult, asTextContentResult } from '@stainless-api/sdk-mcp/tools/types';
44

55
import { Tool } from '@modelcontextprotocol/sdk/types.js';
66
import Stainless from '@stainless-api/sdk';
@@ -86,7 +86,14 @@ export const tool: Tool = {
8686

8787
export const handler = async (client: Stainless, args: Record<string, unknown> | undefined) => {
8888
const body = args as any;
89-
return asTextContentResult(await client.builds.create(body));
89+
try {
90+
return asTextContentResult(await client.builds.create(body));
91+
} catch (error) {
92+
if (error instanceof Stainless.APIError) {
93+
return asErrorResult(error.message);
94+
}
95+
throw error;
96+
}
9097
};
9198

9299
export default { metadata, tool, handler };

packages/mcp-server/src/tools/builds/diagnostics/list-builds-diagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const handler = async (client: Stainless, args: Record<string, unknown> |
8383
try {
8484
return asTextContentResult(await maybeFilter(jq_filter, await response.json()));
8585
} catch (error) {
86-
if (isJqError(error)) {
86+
if (error instanceof Stainless.APIError || isJqError(error)) {
8787
return asErrorResult(error.message);
8888
}
8989
throw error;

packages/mcp-server/src/tools/builds/list-builds.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
import { Metadata, asTextContentResult } from '@stainless-api/sdk-mcp/tools/types';
3+
import { Metadata, asErrorResult, asTextContentResult } from '@stainless-api/sdk-mcp/tools/types';
44

55
import { Tool } from '@modelcontextprotocol/sdk/types.js';
66
import Stainless from '@stainless-api/sdk';
@@ -61,7 +61,14 @@ export const tool: Tool = {
6161
export const handler = async (client: Stainless, args: Record<string, unknown> | undefined) => {
6262
const body = args as any;
6363
const response = await client.builds.list(body).asResponse();
64-
return asTextContentResult(await response.json());
64+
try {
65+
return asTextContentResult(await response.json());
66+
} catch (error) {
67+
if (error instanceof Stainless.APIError) {
68+
return asErrorResult(error.message);
69+
}
70+
throw error;
71+
}
6572
};
6673

6774
export default { metadata, tool, handler };

packages/mcp-server/src/tools/builds/retrieve-builds.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const handler = async (client: Stainless, args: Record<string, unknown> |
4444
try {
4545
return asTextContentResult(await maybeFilter(jq_filter, await client.builds.retrieve(buildId)));
4646
} catch (error) {
47-
if (isJqError(error)) {
47+
if (error instanceof Stainless.APIError || isJqError(error)) {
4848
return asErrorResult(error.message);
4949
}
5050
throw error;

0 commit comments

Comments
 (0)