Skip to main content
Glama

Execute Pica Action

execute_pica_action

Perform operations on third-party platforms via Pica by executing predefined actions such as fetching data or creating tasks. Ensure user intent is confirmed and call get_pica_action_knowledge first for accurate execution.

Instructions

Execute a Pica action to perform actual operations on third-party platforms. CRITICAL: Only call this when the user's intent is to EXECUTE an action (e.g., 'read my last Gmail email', 'fetch 5 contacts from HubSpot', 'create a task in Asana'). DO NOT call this when the user wants to BUILD or CREATE code/forms/applications - in those cases, stop after get_pica_action_knowledge and provide implementation guidance instead. REQUIRED WORKFLOW: Must call get_pica_action_knowledge first. If uncertain about execution intent or parameters, ask for confirmation before proceeding.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction object with ID, path, and method
connectionKeyYesKey of the connection to use
dataNoRequest data (for POST, PUT, etc.)
headersNoAdditional headers
isFormDataNoWhether to send data as multipart/form-data
isFormUrlEncodedNoWhether to send data as application/x-www-form-urlencoded
pathVariablesNoVariables to replace in the path
platformYesPlatform name
queryParamsNoQuery parameters

Implementation Reference

  • The main handler function for the execute_pica_action tool. Initializes Pica if needed and delegates to picaClient.executePassthroughRequest to perform the actual API execution, then formats the response.
    async function handleExecutePicaAction(args: ExecutePicaActionArgs) {
      try {
        const result = await picaClient.executePassthroughRequest(args);
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to execute Pica action: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • src/index.ts:114-121 (registration)
    Registers the execute_pica_action tool with the MCP server, providing the tool config and handler lambda that calls handleExecutePicaAction.
    server.registerTool(
      "execute_pica_action",
      executePicaActionToolConfig,
      async (args: z.infer<typeof executePicaActionZodSchema>) => {
        await initializePica();
        return await handleExecutePicaAction(args as ExecutePicaActionArgs);
      }
    );
  • Zod input schema definition for the execute_pica_action tool parameters.
    export const executePicaActionInputSchema = {
        platform: z.string().describe("Platform name"),
        actionId: z.string().describe("Action ID from search_pica_platform_actions"),
        connectionKey: z.string().describe("Key of the connection to use"),
        data: z.any().optional().describe("Request data (for POST, PUT, etc.)"),
        pathVariables: z.record(z.union([z.string(), z.number(), z.boolean()])).optional().describe("Variables to replace in the path"),
        queryParams: z.record(z.any()).optional().describe("Query parameters"),
        headers: z.record(z.string()).optional().describe("Additional headers"),
        isFormData: z.boolean().optional().describe("Whether to send data as multipart/form-data"),
        isFormUrlEncoded: z.boolean().optional().describe("Whether to send data as application/x-www-form-urlencoded")
    };
  • Tool configuration object including title, description, and reference to input schema.
    export const executePicaActionToolConfig = {
        title: "Execute Pica Action",
        description: "Execute a Pica action to perform actual operations on third-party platforms. CRITICAL: Only call this when the user's intent is to EXECUTE an action (e.g., 'read my last Gmail email', 'fetch 5 contacts from HubSpot', 'create a task in Asana'). DO NOT call this when the user wants to BUILD or CREATE code/forms/applications - in those cases, stop after get_pica_action_knowledge and provide implementation guidance instead. REQUIRED WORKFLOW: Must call get_pica_action_knowledge first. If uncertain about execution intent or parameters, ask for confirmation before proceeding.",
        inputSchema: executePicaActionInputSchema
    };
  • Supporting utility in PicaClient that performs the actual HTTP passthrough request to execute the Pica action, handling path variables, form data, headers, etc.
    async executePassthroughRequest(args: ExecutePicaActionArgs): Promise<ExecutePassthroughResponse> {
      const {
        actionId,
        connectionKey,
        data,
        pathVariables,
        queryParams,
        headers,
        isFormData,
        isFormUrlEncoded,
      } = args;
    
      // Fetch action details
      const action = await this.getActionDetails(actionId);
    
      const method = action.method;
      const contentType = isFormData ? 'multipart/form-data' : isFormUrlEncoded ? 'application/x-www-form-urlencoded' : 'application/json';
    
      const requestHeaders = {
        ...this.generateHeaders(),
        'x-pica-connection-key': connectionKey,
        'x-pica-action-id': action._id,
        'Content-Type': contentType,
        ...headers
      };
    
      const finalActionPath = pathVariables
        ? replacePathVariables(action.path, pathVariables)
        : action.path;
    
      const normalizedPath = finalActionPath.startsWith('/') ? finalActionPath : `/${finalActionPath}`;
      const url = `${this.baseUrl}/v1/passthrough${normalizedPath}`;
    
      // Check if action has "custom" tag and add connectionKey to body if needed
      const isCustomAction = action.tags?.includes('custom');
      let requestData = data;
      if (isCustomAction && method?.toLowerCase() !== 'get') {
        requestData = {
          ...data,
          connectionKey
        };
      }
    
      const requestConfig: RequestConfig = {
        url,
        method,
        headers: requestHeaders,
        params: queryParams
      };
    
      if (method?.toLowerCase() !== 'get') {
        if (isFormData) {
          const formData = new FormData();
    
          if (requestData && typeof requestData === 'object' && !Array.isArray(requestData)) {
            Object.entries(requestData).forEach(([key, value]) => {
              if (typeof value === 'object') {
                formData.append(key, JSON.stringify(value));
              } else {
                formData.append(key, String(value));
              }
            });
          }
    
          requestConfig.data = formData;
          Object.assign(requestConfig.headers, formData.getHeaders());
        } else if (isFormUrlEncoded) {
          const params = new URLSearchParams();
    
          if (requestData && typeof requestData === 'object' && !Array.isArray(requestData)) {
            Object.entries(requestData).forEach(([key, value]) => {
              if (typeof value === 'object') {
                params.append(key, JSON.stringify(value));
              } else {
                params.append(key, String(value));
              }
            });
          }
    
          requestConfig.data = params;
        } else {
          requestConfig.data = requestData;
        }
      }
    
      const sanitizedConfig = {
        ...requestConfig,
        headers: {
          ...requestConfig.headers,
          'x-pica-secret': '***REDACTED***'
        }
      };
    
      try {
        const response: AxiosResponse = await axios(requestConfig);
    
        return {
          requestConfig: sanitizedConfig,
          responseData: response.data
        };
      } catch (error) {
        console.error("Error executing passthrough request:", error);
        if (axios.isAxiosError(error)) {
          throw new Error(`Failed to execute passthrough request: ${error.response?.status} ${error.response?.statusText}`);
        }
        throw new Error("Failed to execute passthrough request");
      }
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes critical behavioral traits: it specifies the tool's role in executing operations on third-party platforms, outlines a mandatory prerequisite workflow (calling get_pica_action_knowledge first), and provides guidance on intent confirmation. However, it lacks details on potential side effects, error handling, or response formats, which would be valuable for a tool with 9 parameters and no output schema.

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 sized and front-loaded, starting with the core purpose and immediately following with critical usage rules. Every sentence earns its place by providing essential guidance. However, it could be slightly more concise by integrating some clauses, and the structure, while clear, isn't perfectly streamlined (e.g., the 'CRITICAL' and 'REQUIRED WORKFLOW' sections are somewhat repetitive in emphasis).

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

Completeness4/5

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

Given the tool's complexity (9 parameters, no output schema, no annotations), the description does a good job of covering usage context, prerequisites, and intent differentiation. It compensates for the lack of annotations by specifying behavioral constraints. However, it doesn't address potential outcomes, error scenarios, or examples of successful execution, which would help an agent understand what to expect after invocation.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description does not add any specific parameter semantics beyond what the schema provides—it doesn't explain how parameters like 'action', 'connectionKey', or 'data' should be derived or used in practice. The baseline score of 3 is appropriate since the schema does the heavy lifting, but the description doesn't enhance parameter understanding.

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's purpose: 'Execute a Pica action to perform actual operations on third-party platforms.' It specifies the verb ('execute') and resource ('Pica action'), and distinguishes it from siblings by contrasting execution with building/creating code/forms/applications, which should use get_pica_action_knowledge instead.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: it states when to use ('when the user's intent is to EXECUTE an action'), when not to use ('DO NOT call this when the user wants to BUILD or CREATE'), and names an alternative ('get_pica_action_knowledge'). It also specifies a required workflow ('Must call get_pica_action_knowledge first') and advises on uncertainty handling ('ask for confirmation before proceeding').

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

Related 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/withoneai/pica-mcp'

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