Skip to content

Commit 9468191

Browse files
chore(internal): codegen related update
1 parent 4bda069 commit 9468191

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ import { McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult }
44
import { Tool } from '@modelcontextprotocol/sdk/types.js';
55
import { readEnv, readEnvOrError } from './server';
66
import { WorkerInput, WorkerOutput } from './code-tool-types';
7+
8+
const prompt = `Runs JavaScript code to interact with the Lithic API.
9+
10+
You are a skilled programmer writing code to interface with the service.
11+
Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
12+
For example:
13+
14+
\`\`\`
15+
async function run(client) {
16+
const card = await client.cards.create({ type: 'SINGLE_USE' });
17+
18+
console.log(card.token);
19+
}
20+
\`\`\`
21+
22+
You will be returned anything that your function returns, plus the results of any console.log statements.
23+
Do not add try-catch blocks for single API calls. The tool will handle errors for you.
24+
Do not add comments unless necessary for generating better code.
25+
Code will run in a container, and cannot interact with the network outside of the given SDK client.
26+
Variables will not persist between calls, so make sure to return or log any data you might need later.`;
27+
728
/**
829
* A tool that runs code against a copy of the SDK.
930
*
@@ -17,8 +38,7 @@ export function codeTool(): McpTool {
1738
const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] };
1839
const tool: Tool = {
1940
name: 'execute',
20-
description:
21-
'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
41+
description: prompt,
2242
inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
2343
};
2444
const handler = async (_: unknown, args: any): Promise<ToolCallResult> => {

0 commit comments

Comments
 (0)