Skip to main content
Glama
InsForge

Insforge MCP Server

create-function

Create edge functions for Deno runtime by writing code to files for version control, enabling serverless execution in production cloud infrastructure.

Instructions

Create a new edge function that runs in Deno runtime. The code must be written to a file first for version control

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
slugNo
descriptionNo
statusNoactive
codeFileYesPath to JavaScript file containing the function code. Must export: module.exports = async function(request) { return new Response(...) }

Implementation Reference

  • Core handler that reads JavaScript code from a specified file and sends a POST request to the API endpoint to create a new edge function. Handles file reading errors and API responses, formats success/error messages.
    withUsageTracking('create-function', async (args) => {
      try {
        let code: string;
        try {
          code = await fs.readFile(args.codeFile, 'utf-8');
        } catch (fileError) {
          throw new Error(
            `Failed to read code file '${args.codeFile}': ${fileError instanceof Error ? fileError.message : 'Unknown error'}`
          );
        }
    
        const response = await fetch(`${API_BASE_URL}/api/functions`, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
            'x-api-key': getApiKey(),
          },
          body: JSON.stringify({
            slug: args.slug,
            name: args.name,
            code: code,
            description: args.description,
            status: args.status,
          }),
        });
    
        const result = await handleApiResponse(response);
    
        return await addBackgroundContext({
          content: [
            {
              type: 'text',
              text: formatSuccessMessage(
                `Edge function '${args.slug}' created successfully from ${args.codeFile}`,
                result
              ),
            },
          ],
        });
      } catch (error) {
        const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: 'text',
              text: `Error creating function: ${errMsg}`,
            },
          ],
          isError: true,
        };
      }
    })
  • Input schema definition for the create-function tool. Uses functionUploadRequestSchema (omitting code field) and adds required codeFile parameter pointing to the JS source file.
    {
      ...functionUploadRequestSchema.omit({ code: true }).shape,
      codeFile: z
        .string()
        .describe(
          'Path to JavaScript file containing the function code. Must export: module.exports = async function(request) { return new Response(...) }'
        ),
    },
  • Full registration of the 'create-function' tool on the MCP server, including name, description, input schema, and handler function wrapped with usage tracking.
    server.tool(
      'create-function',
      'Create a new edge function that runs in Deno runtime. The code must be written to a file first for version control',
      {
        ...functionUploadRequestSchema.omit({ code: true }).shape,
        codeFile: z
          .string()
          .describe(
            'Path to JavaScript file containing the function code. Must export: module.exports = async function(request) { return new Response(...) }'
          ),
      },
      withUsageTracking('create-function', async (args) => {
        try {
          let code: string;
          try {
            code = await fs.readFile(args.codeFile, 'utf-8');
          } catch (fileError) {
            throw new Error(
              `Failed to read code file '${args.codeFile}': ${fileError instanceof Error ? fileError.message : 'Unknown error'}`
            );
          }
    
          const response = await fetch(`${API_BASE_URL}/api/functions`, {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json',
              'x-api-key': getApiKey(),
            },
            body: JSON.stringify({
              slug: args.slug,
              name: args.name,
              code: code,
              description: args.description,
              status: args.status,
            }),
          });
    
          const result = await handleApiResponse(response);
    
          return await addBackgroundContext({
            content: [
              {
                type: 'text',
                text: formatSuccessMessage(
                  `Edge function '${args.slug}' created successfully from ${args.codeFile}`,
                  result
                ),
              },
            ],
          });
        } catch (error) {
          const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
          return {
            content: [
              {
                type: 'text',
                text: `Error creating function: ${errMsg}`,
              },
            ],
            isError: true,
          };
        }
      })
    );
  • Calls registerInsforgeTools to register all tools (including create-function) on the HTTP MCP server.
    registerInsforgeTools(mcpServer, {
      apiKey,
      apiBaseUrl,
    });
  • Calls registerInsforgeTools to register all tools (including create-function) on the stdio MCP server.
    const toolsConfig = registerInsforgeTools(server, {
      apiKey: api_key,
      apiBaseUrl: api_base_url || process.env.API_BASE_URL,
    });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the Deno runtime and a file prerequisite, but fails to disclose critical behavioral aspects: whether this is a mutating operation, what permissions are required, whether the function is immediately deployable, what happens on failure, or what the tool returns. The description is insufficient for a creation tool with zero annotation coverage.

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

Conciseness4/5

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

The description is appropriately concise with two clear sentences. The first sentence states the core purpose, and the second adds an important prerequisite. There's no unnecessary verbiage, though the structure could be slightly improved by front-loading the prerequisite more explicitly.

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

Completeness2/5

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

For a creation tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It lacks information about what the tool returns, error conditions, side effects, authentication requirements, and detailed parameter semantics. The prerequisite about file writing is helpful but insufficient for the tool's complexity and lack of structured documentation.

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

Parameters2/5

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

With only 20% schema description coverage (only 'codeFile' has a description), the description must compensate but adds minimal parameter context. It mentions 'code must be written to a file' which relates to 'codeFile', but provides no semantic context for 'name', 'slug', 'description', or 'status' parameters. The description doesn't explain what these parameters mean or how they affect the created function.

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

Purpose4/5

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

The description clearly states the action ('Create a new edge function') and specifies the runtime environment ('runs in Deno runtime'), which distinguishes it from generic creation tools. However, it doesn't explicitly differentiate from sibling tools like 'update-function' or 'delete-function' beyond the basic verb.

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?

The description provides no guidance on when to use this tool versus alternatives like 'update-function' or 'get-function'. It mentions a prerequisite ('code must be written to a file first') but doesn't explain when this creation method is preferred over other approaches or what scenarios warrant its use.

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/InsForge/insforge-mcp'

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