Skip to main content
Glama
soil-dev

capsulemcp

list_lostreasons

Retrieve all configured opportunity-loss reasons to analyze closed-lost opportunities. Understand why deals are lost to improve sales processes.

Instructions

List all configured opportunity-loss reasons (e.g. 'Poor Qualification', 'Lost to competitor'). Useful for analysing closed-lost opportunities by reason.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
perPageNoPage size, max 100. Defaults to 100 for reference data.

Implementation Reference

  • The handler function and schema for list_lostreasons. Makes a GET request to /lostreasons with pagination and returns the data (including lostReasons array) plus a nextPage cursor.
    export const listLostReasonsSchema = z.object({ ...paginationFields });
    
    export async function listLostReasons(input: z.infer<typeof listLostReasonsSchema>) {
      // Note response key: `lostReasons` (camelCase plural).
      const { data, nextPage } = await capsuleGet<{ lostReasons: unknown[] }>("/lostreasons", {
        page: input.page ?? 1,
        perPage: input.perPage ?? 100,
      });
      return { ...data, nextPage };
    }
  • Zod schema for list_lostreasons input: accepts optional page (positive int) and perPage (1-100, defaults to 100) fields via spread of paginationFields.
    export const listLostReasonsSchema = z.object({ ...paginationFields });
  • src/server.ts:887-893 (registration)
    Registration of the 'list_lostreasons' tool via registerTool helper, with description and reference to the schema/handler imported from metadata.ts.
    registerTool(
      server,
      "list_lostreasons",
      "List all configured opportunity-loss reasons (e.g. 'Poor Qualification', 'Lost to competitor'). Useful for analysing closed-lost opportunities by reason.",
      listLostReasonsSchema,
      listLostReasons,
    );
  • The registerTool helper that wraps the handler in MCP's text-content response format and registers it on the McpServer.
    export function registerTool<Schema extends z.ZodObject<ZodRawShape>>(
      server: McpServer,
      name: string,
      description: string,
      schema: Schema,
      handler: (input: z.infer<Schema>) => Promise<unknown>,
    ): void {
      // Use the SDK config-form registerTool with the full Zod schema. The
      // deprecated shape overload rebuilds z.object(schema.shape), which drops
      // object-level refinements such as superRefine.
      const registerWithSchema = server.registerTool.bind(server) as (
        toolName: string,
        config: { description: string; inputSchema: Schema },
        callback: (input: z.infer<Schema>) => Promise<CallToolResult>,
      ) => void;
    
      registerWithSchema(name, { description, inputSchema: schema }, async (input) => {
        const result = await handler(input);
        return wrapAsText(result);
      });
    }
  • Reference to list_lostreasons in the lostReasonId field description of the opportunity update schema - tells users to discover valid IDs via list_lostreasons.
    lostReasonId: z
      .number()
      .int()
      .positive()
      .optional()
      .describe(
        "Reason the opportunity was lost. Only meaningful when transitioning to a Lost milestone — Capsule silently drops it for other milestones. Without this set, a connector-driven Lost-close leaves `lostReason: null`. Discover IDs via list_lostreasons.",
      ),
Behavior2/5

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

No annotations are provided, so the description alone must convey behavioral traits. It indicates a read-only listing but omits details such as side effects, authentication requirements, rate limits, pagination behavior, or what happens if no reasons are configured. The lack of output schema information further reduces transparency.

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 concise with two sentences, front-loading the core action. It avoids fluff but could benefit from structured bullet points or additional context without sacrificing brevity. The current form is efficient though slightly incomplete.

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?

Given the absence of an output schema and annotations, the description should explain return values, error conditions, and default behavior for parameters. It fails to do so, leaving agents uncertain about the output format and edge cases. The simple nature of the tool warrants more detail.

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 50% schema description coverage (only perPage has a description), the description adds no parameter insights. It does not mention that page and perPage control pagination, nor does it explain default behavior. The description should have clarified these aspects to compensate for the schema gaps.

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 verb 'List' and the resource 'opportunity-loss reasons', with concrete examples. It unambiguously identifies the tool's purpose and distinguishes it from sibling list tools by specifying the exact subject.

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

Usage Guidelines3/5

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

The description mentions it's 'useful for analysing closed-lost opportunities by reason', providing a use case. However, it does not explicitly guide when to use this tool versus alternatives like list_stages or filter_opportunities, nor does it state when not to use it.

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/soil-dev/capsulemcp'

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