Skip to main content
Glama

get_workflow

Retrieve API endpoints with dependencies and schemas to plan multi-step workflows for accomplishing tasks, enabling structured API call execution.

Instructions

Get relevant endpoints with dependency resolution and full schemas for accomplishing a task. Returns search results expanded with their dependencies so you can plan and execute the right API calls in the right order. After reviewing the results, use call_api to execute each step.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesWhat you want to accomplish (e.g., 'create a user and place an order')
api_idYesThe API to use
max_stepsNoMaximum number of endpoints to return (default: 5)

Implementation Reference

  • Implementation of the get_workflow tool handler. It performs vector search, graph expansion for dependencies, fetches schemas, orders steps by dependency, and returns the workflow plan.
    async def _get_workflow(self, args: dict[str, Any]) -> ToolResult:
        """Get relevant endpoints with dependencies and schemas for a task."""
        query = args["query"]
        api_id = args["api_id"]
        max_steps = args.get("max_steps", 5)
    
        # Step 1: Vector search
        search_results = self.vector_searcher.search(query, api_id=api_id, top_k=10)
    
        if not search_results:
            return ToolResult(
                success=False,
                data=None,
                error=f"No endpoints found for query: {query}",
            )
    
        # Step 2: Graph expansion (adds dependencies the search might have missed)
        expansion = self.graph_expander.expand(
            search_results, api_id, max_depth=2, max_total=10
        )
    
        # Step 3: Collect endpoint data
        step_data = []
        step_endpoint_ids = set()
        for ep in expansion.endpoints[:max_steps]:
            endpoint = self.spec_store.get_endpoint(api_id, ep.endpoint_id)
            if endpoint:
                schema = self.schema_formatter.format_endpoint_for_call(endpoint)
                dependencies = self.graph_store.get_dependencies(api_id, ep.endpoint_id)
                step_endpoint_ids.add(ep.endpoint_id)
                step_data.append(
                    {
                        "endpoint_id": ep.endpoint_id,
                        "path": ep.path,
                        "method": ep.method,
                        "summary": ep.summary,
                        "relevance_score": round(ep.score, 3),
                        "is_dependency": ep.is_dependency,
                        "dependencies": dependencies,
                        "schema": schema,
                    }
                )
    
        # Step 4: Order steps — dependencies (providers) before dependents (consumers)
        # Simple heuristic: endpoints marked as dependencies come first,
        # then sort by relevance score within each group.
        # This handles cycles gracefully (common in auto-generated dependency graphs).
        dep_steps = [s for s in step_data if s["is_dependency"]]
        direct_steps = [s for s in step_data if not s["is_dependency"]]
        dep_steps.sort(key=lambda s: s["relevance_score"], reverse=True)
        direct_steps.sort(key=lambda s: s["relevance_score"], reverse=True)
        step_data = dep_steps + direct_steps
    
        # Number the steps
        steps = []
        for i, step in enumerate(step_data):
            step["step"] = i + 1
            steps.append(step)
    
        return ToolResult(
            success=True,
            data={
                "query": query,
                "api_id": api_id,
                "steps": steps,
                "total_endpoints": len(steps),
                "message": "Steps are ordered by dependency (prerequisites first). Use call_api to execute each step.",
            },
        )
  • MCP definition and schema for the get_workflow tool.
        "name": "get_workflow",
        "description": "Get relevant endpoints with dependency resolution and full schemas "
        "for accomplishing a task. Returns search results expanded with their dependencies "
        "so you can plan and execute the right API calls in the right order. "
        "After reviewing the results, use call_api to execute each step.",
        "inputSchema": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "What you want to accomplish (e.g., 'create a user and place an order')",
                },
                "api_id": {
                    "type": "string",
                    "description": "The API to use",
                },
                "max_steps": {
                    "type": "integer",
                    "description": "Maximum number of endpoints to return (default: 5)",
                    "default": 5,
                },
            },
            "required": ["query", "api_id"],
        },
    },
  • Registration of the get_workflow handler in the ToolRegistry.
    "get_workflow": self._get_workflow,
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. It effectively discloses key behavioral traits: returns 'search results expanded with their dependencies' and enables planning of 'API calls in the right order.' Missing minor details like rate limits or specific error conditions, but captures the essential read-only, planning-oriented nature.

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 zero waste. Front-loaded with purpose ('Get relevant endpoints...'), followed by return value description, and closes with explicit workflow guidance. Every sentence earns its place.

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?

Despite no output schema and no annotations, the description adequately explains what the tool returns ('search results expanded with their dependencies') and the next step in the workflow. Sufficient for a discovery/planning tool, though explicit mention of output structure would improve this to a 5.

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?

Input schema has 100% description coverage with clear examples (e.g., 'create a user and place an order'). The description mentions 'accomplishing a task' which conceptually maps to the 'query' parameter, but does not add syntax details or formatting rules beyond what the schema already provides. Baseline score appropriate for high schema coverage.

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?

States specific action ('Get relevant endpoints') with key features ('dependency resolution and full schemas') and scope ('accomplishing a task'). Clearly distinguishes from sibling 'call_api' by emphasizing planning versus execution, and from 'search_endpoints' by highlighting dependency resolution.

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 directs the workflow: 'After reviewing the results, use call_api to execute each step.' This creates clear separation between when to use this tool (planning/discovery) versus the sibling execution tool.

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/nk3750/jitapi'

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