execute_go_playground_url
Run Go code from any Go Playground URL in the sandbox, with optional vet check. Provide the URL and receive execution results.
Instructions
Execute Go code from an existing Go Playground URL
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The Go Playground URL to execute code from (e.g., https://go.dev/play/abc123 or https://play.golang.org/p/abc123) | |
| withVet | No | Whether to run go vet on the code (default: true) |
Implementation Reference
- src/mcp-server.ts:282-294 (handler)Handler function that orchestrates the execute_go_playground_url tool: extracts url and withVet from args, calls client.executeUrl(), and formats the response.
const createExecuteGoPlaygroundUrlHandler = (client: ReturnType<typeof createGoPlaygroundClient>) => async (args: ExecuteGoPlaygroundUrlArgs): Promise<MCPToolResponse> => { try { const { url, withVet = true } = args; const result = await client.executeUrl(url, withVet); const responseText = formatRunResponse(result); return createSuccessResponse(responseText); } catch (error) { console.error('Error in handleExecuteGoPlaygroundUrl:', error); return createErrorResponse(error); } }; - src/types.ts:95-98 (schema)Type definition for ExecuteGoPlaygroundUrlArgs with readonly url (GoPlaygroundUrl) and optional withVet boolean.
export type ExecuteGoPlaygroundUrlArgs = { readonly url: GoPlaygroundUrl; readonly withVet?: boolean; }; - src/types.ts:220-230 (schema)Type guard function isExecuteGoPlaygroundUrlArgs that validates runtime arguments have a valid playground URL and optionally a boolean withVet.
export const isExecuteGoPlaygroundUrlArgs = ( args: unknown ): args is ExecuteGoPlaygroundUrlArgs => { return ( typeof args === 'object' && args !== null && 'url' in args && isGoPlaygroundUrl((args as Record<string, unknown>).url) && (!('withVet' in args) || typeof (args as Record<string, unknown>).withVet === 'boolean') ); - src/mcp-server.ts:117-136 (registration)Tool registration with name 'execute_go_playground_url', description, and inputSchema defining url (string) and withVet (optional boolean) parameters.
{ name: TOOL_NAMES.EXECUTE_GO_PLAYGROUND_URL, description: 'Execute Go code from an existing Go Playground URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The Go Playground URL to execute code from (e.g., https://go.dev/play/abc123 or https://play.golang.org/p/abc123)', }, withVet: { type: 'boolean', description: 'Whether to run go vet on the code (default: true)', default: true, }, }, required: ['url'], }, }, ] as const; - src/go-playground-client.ts:318-334 (helper)Core implementation: reads code from a playground URL using readGoPlaygroundUrl, then executes it using runGoCode with the withVet option.
// Function to execute code from playground URL export const executeGoPlaygroundUrl = (config: Partial<GoPlaygroundConfig> = {}) => async (url: string, withVet: boolean = true): Promise<MCPGoPlaygroundResult> => { // First read the code from the URL const readResult = await readGoPlaygroundUrl(config)(url); if (!readResult.success) { return { success: false, errors: readResult.error, }; } // Then execute the code const runCode = runGoCode(config); return await runCode(readResult.code, withVet); };