Skip to main content
Glama

create_job

Escrow USDC payment by creating a Job that releases funds only after a Provider delivers and an Evaluator approves. Designed for agent-to-agent service delivery.

Instructions

Create a Job that escrows USDC payment until a Provider delivers and an Evaluator approves. Use this for A2A service delivery (vs send_payment for direct transfers). Confirm budget + provider with user first. Provider must have a CardZero wallet (Sprint 9 MVP requirement).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
providerAddressYesProvider's wallet address (0x-prefixed, must be a CardZero wallet)
budgetUsdcYesBudget in microUSDC (6 decimals), e.g. "10000000" for $10 USDC
expiredAtYesUnix timestamp (seconds). Must be at least 86400 (1 day) from now.
titleYesShort title describing the work
descriptionYesDetailed description: what Provider must deliver to be paid
evaluatorRuleYesEvaluator rule that decides complete/reject when Provider submits
idempotencyKeyNoOptional: prevent duplicate Jobs on retry

Implementation Reference

  • src/index.ts:231-262 (registration)
    Registration of the 'create_job' tool on the MCP server. Uses server.tool() with Zod schema for inputs and an async handler.
    server.tool(
      "create_job",
      "Create a Job that escrows USDC payment until a Provider delivers and an Evaluator approves. Use this for A2A service delivery (vs send_payment for direct transfers). Confirm budget + provider with user first. Provider must have a CardZero wallet (Sprint 9 MVP requirement).",
      {
        providerAddress: z.string().describe("Provider's wallet address (0x-prefixed, must be a CardZero wallet)"),
        budgetUsdc: z.string().describe('Budget in microUSDC (6 decimals), e.g. "10000000" for $10 USDC'),
        expiredAt: z.number().describe("Unix timestamp (seconds). Must be at least 86400 (1 day) from now."),
        title: z.string().describe("Short title describing the work"),
        description: z.string().describe("Detailed description: what Provider must deliver to be paid"),
        evaluatorRule: z.object({
          type: z.enum(["manual", "json_schema", "http_check"]).describe("'manual' = needs human, 'json_schema' = MVP auto-approve on submit, 'http_check' = fetch URL and check status"),
          url: z.string().optional().describe("For http_check: URL to fetch"),
          expectedStatus: z.number().optional().describe("For http_check: expected HTTP status (default 200)"),
          timeoutMs: z.number().optional().describe("For http_check: fetch timeout in ms (default 5000)"),
          schema: z.object({}).passthrough().optional().describe("For json_schema (reserved for full validation)"),
        }).describe("Evaluator rule that decides complete/reject when Provider submits"),
        idempotencyKey: z.string().optional().describe("Optional: prevent duplicate Jobs on retry"),
      },
      async ({ providerAddress, budgetUsdc, expiredAt, title, description, evaluatorRule, idempotencyKey }) => {
        try {
          const body: Record<string, unknown> = {
            providerAddress, budgetUsdc, expiredAt, title, description, evaluatorRule,
          };
          if (idempotencyKey) body.idempotencyKey = idempotencyKey;
          const res = await callApi("POST", "/jobs", body);
          if (!res.ok) return errorResponse("Create job failed", res);
          return successResponse(res.json);
        } catch (e) {
          return { content: [{ type: "text" as const, text: `Create job error: ${e}` }], isError: true };
        }
      },
    );
  • The async handler for create_job. Constructs the request body from inputs, POSTs to '/jobs' via callApi, returns success or error response.
    async ({ providerAddress, budgetUsdc, expiredAt, title, description, evaluatorRule, idempotencyKey }) => {
      try {
        const body: Record<string, unknown> = {
          providerAddress, budgetUsdc, expiredAt, title, description, evaluatorRule,
        };
        if (idempotencyKey) body.idempotencyKey = idempotencyKey;
        const res = await callApi("POST", "/jobs", body);
        if (!res.ok) return errorResponse("Create job failed", res);
        return successResponse(res.json);
      } catch (e) {
        return { content: [{ type: "text" as const, text: `Create job error: ${e}` }], isError: true };
      }
    },
  • Zod schema defining input parameters: providerAddress, budgetUsdc, expiredAt, title, description, evaluatorRule (with type/url/expectedStatus/timeoutMs/schema), and optional idempotencyKey.
    {
      providerAddress: z.string().describe("Provider's wallet address (0x-prefixed, must be a CardZero wallet)"),
      budgetUsdc: z.string().describe('Budget in microUSDC (6 decimals), e.g. "10000000" for $10 USDC'),
      expiredAt: z.number().describe("Unix timestamp (seconds). Must be at least 86400 (1 day) from now."),
      title: z.string().describe("Short title describing the work"),
      description: z.string().describe("Detailed description: what Provider must deliver to be paid"),
      evaluatorRule: z.object({
        type: z.enum(["manual", "json_schema", "http_check"]).describe("'manual' = needs human, 'json_schema' = MVP auto-approve on submit, 'http_check' = fetch URL and check status"),
        url: z.string().optional().describe("For http_check: URL to fetch"),
        expectedStatus: z.number().optional().describe("For http_check: expected HTTP status (default 200)"),
        timeoutMs: z.number().optional().describe("For http_check: fetch timeout in ms (default 5000)"),
        schema: z.object({}).passthrough().optional().describe("For json_schema (reserved for full validation)"),
      }).describe("Evaluator rule that decides complete/reject when Provider submits"),
      idempotencyKey: z.string().optional().describe("Optional: prevent duplicate Jobs on retry"),
    },
  • callApi helper function used by the create_job handler to make authenticated HTTP requests to the CardZero API.
    async function callApi(
      method: "GET" | "POST",
      path: string,
      body?: Record<string, unknown>,
      auth = true,
    ): Promise<ApiResult> {
      if (auth && !API_KEY) {
        return {
          ok: false,
          status: 401,
          json: {
            error: "config_missing",
            message: "CARDZERO_API_KEY is not set. Get one at https://cardzero.ai",
          },
        };
      }
    
      const headers: Record<string, string> = {};
      if (auth) headers["Authorization"] = `Bearer ${API_KEY}`;
      if (body) headers["Content-Type"] = "application/json";
    
      const res = await fetch(`${API_URL}${path}`, {
        method,
        headers,
        body: body ? JSON.stringify(body) : undefined,
      });
    
      const json = await res.json() as Record<string, unknown>;
      return { ok: res.ok, status: res.status, json };
    }
Behavior3/5

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

Without annotations, the description carries full burden. It explains the escrow mechanism and provider requirement but omits details like expiry behavior, cancellability, or what happens on submission failure. Adequate but not comprehensive for a financial tool.

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

Conciseness5/5

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

Three sentences with no waste. First sentence states purpose, second gives usage context and alternative, third provides prerequisite. Efficiently structured and front-loaded.

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?

Given the complexity (7 params, nested evaluatorRule, no output schema), the description is relatively complete but misses behavioral details like what happens when job expires or if conditions aren't met. Without annotations, more context on return values or side effects would improve completeness.

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 coverage is 100%, so the input schema already documents all parameters with descriptions. The description adds no additional semantic value for parameters beyond usage guidance, thus baseline score of 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?

Description clearly states the tool creates a job that escrows USDC for A2A service delivery. It distinguishes itself from send_payment for direct transfers, providing a specific verb and resource with a clear delineation from siblings.

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?

Explicitly tells when to use (A2A service delivery vs send_payment) and includes a prerequisite: confirm budget and provider with user, and provider must have a CardZero wallet. This is high-quality guidance for an AI agent.

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/mrocker/cardzero-mcp'

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