execute_go_playground_url
Execute Go code from an existing Go Playground URL to run programs in the sandbox environment, with optional go vet analysis for code quality checks.
Instructions
Execute Go code from an existing Go Playground URL
Input Schema
TableJSON 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)Factory function creating the MCP tool handler for 'execute_go_playground_url'. Extracts args, calls client.executeUrl, formats response, handles errors.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/go-playground-client.ts:319-334 (helper)Core helper function implementing the execution: reads Go code from playground URL, then runs it using runGoCode.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); };
- src/mcp-server.ts:300-306 (registration)Registers the execute_go_playground_url handler in the tool router's handlers map.const handlers = { [TOOL_NAMES.RUN_GO_CODE]: createRunGoCodeHandler(client), [TOOL_NAMES.SHARE_GO_CODE]: createShareGoCodeHandler(client), [TOOL_NAMES.RUN_AND_SHARE_GO_CODE]: createRunAndShareGoCodeHandler(client), [TOOL_NAMES.READ_GO_PLAYGROUND_URL]: createReadGoPlaygroundUrlHandler(client), [TOOL_NAMES.EXECUTE_GO_PLAYGROUND_URL]: createExecuteGoPlaygroundUrlHandler(client), } as const;
- src/mcp-server.ts:117-135 (schema)Tool definition including name, description, and input schema for 'execute_go_playground_url'.{ 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'], }, },
- src/types.ts:220-231 (schema)Type guard/validator for ExecuteGoPlaygroundUrlArgs used in handler dispatch.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') ); };