Skip to main content
Glama
samber

Go Playground MCP Server

by samber

share_go_code

Generate a shareable URL from Go code to enable distribution and collaboration.

Instructions

Share Go code and get a shareable URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe Go code to share

Implementation Reference

  • Tool registration for share_go_code in the MCP server tool definitions
    {
      name: TOOL_NAMES.SHARE_GO_CODE,
      description: 'Share Go code and get a shareable URL',
      inputSchema: {
        type: 'object',
        properties: {
          code: {
            type: 'string',
            description: 'The Go code to share',
          },
        },
        required: ['code'],
      },
    },
  • MCP handler for share_go_code - calls client.shareCode and formats the response
    const createShareGoCodeHandler =
      (client: ReturnType<typeof createGoPlaygroundClient>) =>
      async (args: ShareGoCodeArgs): Promise<MCPToolResponse> => {
        try {
          const { code } = args;
          const shareUrl = await client.shareCode(code);
    
          const responseText = shareUrl
            ? `✅ Code shared successfully!\n\n**Share URL:** ${shareUrl}`
            : '❌ Failed to share code. Please try again.';
    
          return createSuccessResponse(responseText);
        } catch (error) {
          console.error('Error in handleShareGoCode:', error);
          return createErrorResponse(error);
        }
      };
  • Type definition for share_go_code arguments
    export type ShareGoCodeArgs = {
      readonly code: GoCode;
    };
  • Type guard for ShareGoCodeArgs runtime validation
    export const isShareGoCodeArgs = (args: unknown): args is ShareGoCodeArgs => {
      return (
        typeof args === 'object' &&
        args !== null &&
        'code' in args &&
        isGoCode((args as Record<string, unknown>).code)
      );
    };
  • Core shareGoCode function that calls the Go Playground /share API and returns a shareable URL
    export const shareGoCode =
      (config: Partial<GoPlaygroundConfig> = {}) =>
      async (code: string): Promise<ShareUrl | null> => {
        // Validate input
        const validationResult = validateGoCode(code);
        if (!validationResult.success) {
          console.error(
            'Invalid Go code for sharing:',
            validationResult.error.message
          );
          return null;
        }
    
        const finalConfig = { ...createDefaultConfig(), ...config };
        const client = createHttpClient(finalConfig);
    
        try {
          const request: GoPlaygroundShareRequest = {
            body: validationResult.data,
          };
    
          const response = await client.post<GoPlaygroundShareResponse>(
            '/share',
            request.body,
            {
              headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
              },
            }
          );
    
          const shareId = response.data;
          // Use the frontend URL for sharing, not the API URL
          return createShareUrl(`${finalConfig.frontendUrl}/p/${shareId}`);
        } catch (error) {
          console.error('Failed to share code:', error);
          return null;
        }
      };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It states it shares code and returns a URL, but omits details such as whether the code is executed, if there are side effects, authentication needs, or rate limits. This is insufficient for a mutation-like operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at one sentence, but it is too minimal to be considered well-structured. It lacks necessary context, making it less helpful despite its brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema or further details are provided. The description mentions a 'shareable URL' but does not specify its format or content. Given the presence of sibling tools with overlapping functionality, more context is needed for complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already covers the single parameter 'code' with a description. The tool description adds no additional meaning beyond the schema, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool shares Go code and returns a shareable URL. It is specific about the verb ('Share') and resource ('Go code'), and it naturally distinguishes from siblings like run_go_code (executes without sharing) and run_and_share_go_code (does both).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage guidelines are provided. The description does not indicate when to use this tool versus siblings like run_and_share_go_code or execute_go_playground_url, nor does it specify prerequisites or alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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