> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agent-corex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute a tool

> Execute a tool with specified parameters. Returns the result of the tool execution.
The tool must be available (connected via MCP server) and you must have proper authentication.




## OpenAPI

````yaml /api-reference/openapi.yaml post /execute_tool
openapi: 3.0.0
info:
  title: Agent-CoreX API
  description: Dynamic tool retrieval and execution for AI agents using MCP servers
  version: 1.0.0
  contact:
    name: Agent-CoreX Support
    email: support@agent-corex.com
    url: https://github.com/anthropics/agent-corex
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.agent-corex.com/v1
    description: Production API
  - url: https://staging-api.agent-corex.com/v1
    description: Staging API
  - url: http://localhost:3000/v1
    description: Local development
security:
  - bearerAuth: []
  - apiKey: []
tags:
  - name: Tools
    description: Tool discovery and execution
  - name: Servers
    description: MCP server management
  - name: System
    description: System and health endpoints
externalDocs:
  description: Full documentation
  url: https://docs.agent-corex.com
paths:
  /execute_tool:
    post:
      tags:
        - Tools
      summary: Execute a tool
      description: >
        Execute a tool with specified parameters. Returns the result of the tool
        execution.

        The tool must be available (connected via MCP server) and you must have
        proper authentication.
      operationId: executeTool
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExecuteToolRequest'
            examples:
              create_pr:
                summary: Create a GitHub PR
                value:
                  tool_name: create-pull-request
                  params:
                    repository: owner/repo
                    title: Add new feature
                    from_branch: feature/x
                    to_branch: main
                    body: This PR adds a new feature
              deploy:
                summary: Deploy to AWS
                value:
                  tool_name: deploy-aws-lambda
                  params:
                    function_name: my-function
                    zip_file: function.zip
                    environment: production
      responses:
        '200':
          description: Tool executed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecuteToolResponse'
              examples:
                success:
                  summary: Successful execution
                  value:
                    success: true
                    data:
                      tool_name: create-pull-request
                      status: success
                      result:
                        pr_number: 123
                        pr_url: https://github.com/owner/repo/pull/123
                        created_at: '2024-01-15T10:30:00Z'
                      execution_time_ms: 245
                      tokens_used:
                        input: 150
                        output: 200
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Tool not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: TOOL_NOT_FOUND
                  message: Tool 'create-pull-request' not found or not connected
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ExecuteToolRequest:
      type: object
      required:
        - tool_name
        - params
      properties:
        tool_name:
          type: string
          description: Name of the tool to execute
          example: create-pull-request
        params:
          type: object
          description: Tool-specific parameters
          additionalProperties: true
        timeout:
          type: integer
          description: Execution timeout in milliseconds
          default: 30000
          minimum: 1000
          maximum: 300000
        user_id:
          type: string
          description: Override current user (admin only)
    ExecuteToolResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          type: object
          properties:
            tool_name:
              type: string
            status:
              type: string
              enum:
                - success
                - failure
                - timeout
            result:
              type: object
              description: Tool execution result
              additionalProperties: true
            error:
              type: object
              description: Error details if execution failed
            execution_time_ms:
              type: integer
            tokens_used:
              type: object
              properties:
                input:
                  type: integer
                output:
                  type: integer
        meta:
          $ref: '#/components/schemas/ResponseMeta'
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - INVALID_REQUEST
                - UNAUTHORIZED
                - FORBIDDEN
                - NOT_FOUND
                - RATE_LIMITED
                - SERVER_ERROR
            message:
              type: string
            details:
              type: object
              additionalProperties: true
        meta:
          $ref: '#/components/schemas/ResponseMeta'
    ResponseMeta:
      type: object
      properties:
        request_id:
          type: string
          description: Unique request identifier
        timestamp:
          type: string
          format: date-time
          description: Request timestamp
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Too many requests
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
        X-RateLimit-Remaining:
          schema:
            type: integer
        X-RateLimit-Reset:
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token obtained from dashboard
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: API key in format "Bearer YOUR_API_KEY"

````