Skip to main content
Glama

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
NameRequiredDescriptionDefault
urlYesThe Go Playground URL to execute code from (e.g., https://go.dev/play/abc123 or https://play.golang.org/p/abc123)
withVetNoWhether to run go vet on the code (default: true)

Implementation Reference

  • 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); } };
  • 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); };
  • 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;
  • 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'], }, },
  • 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') ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/samber/go-playground-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server