Skip to content

Latest commit

 

History

History
131 lines (113 loc) · 4.52 KB

File metadata and controls

131 lines (113 loc) · 4.52 KB

MCP Server API Endpoints

This document outlines the API endpoints exposed by the MCP (Management and Control Platform) server, which integrates with Confluence Cloud for AI agent management and reversibility.

Base URL

The MCP server API is available at http://127.0.0.1:8000 (default).

Endpoints

1. GET /

  • Description: Root endpoint for checking if the MCP server is running.
  • Response:
    {
      "message": "MCP Server is running"
    }

2. POST /api/agents/register

  • Description: Registers a new AI agent with the MCP server. This allows the MCP to manage the agent's identity and Confluence access credentials.
  • Request Body:
    {
      "agent_name": "Augment Agent",
      "confluence_user_email": "agent@example.com",
      "confluence_api_token": "YOUR_AGENT_API_TOKEN"
    }
  • Response:
    {
      "status": "Agent registered successfully",
      "agent_id": "agent-1"
    }

3. GET /api/agents

  • Description: Retrieves a list of all registered AI agents.
  • Response: A JSON array of agent objects.
    [
      {
        "agent_id": "agent-1",
        "agent_name": "Augment Agent"
      }
    ]

4. POST /webhook/confluence

  • Description: Receives webhook notifications from Confluence. This endpoint is intended to be configured in Confluence to receive real-time updates (e.g., page updates). It logs the incoming payload and, for page update events, records a basic change entry in the server's in-memory tracked_changes list.
  • Request Body: Confluence webhook payload (JSON format). The structure depends on the Confluence event.
  • Response:
    {
      "status": "success"
    }

5. GET /api/changes

  • Description: Retrieves a list of all changes currently tracked by the MCP server. This includes simulated AI agent actions and events received via Confluence webhooks.
  • Response: A JSON array of change objects. Each object contains details like change_id, agent_id, page_id, action, before_state, after_state, and timestamp.
    [
      {
        "change_id": "agent-change-1",
        "agent_id": "agent-1",
        "page_id": "622593",
        "action": "update",
        "before_state": {
          "title": "Old Title",
          "content": "Old content...",
          "version": 1
        },
        "after_state": {
          "title": "New Title",
          "content": "New content...",
          "version": 2
        },
        "timestamp": "2023-10-27T10:00:00.000000"
      },
      // ... more change objects
    ]

6. POST /api/confluence/update_page/{page_id}

  • Description: Allows a registered AI agent to update a specific Confluence page. The MCP server uses the agent's registered credentials to perform the update via the Confluence API and tracks the change.
  • Path Parameters:
    • page_id (string): The ID of the Confluence page to be updated.
  • Request Body:
    {
      "agent_id": "agent-1",
      "title": "New Page Title",
      "content": "New page content in storage format (e.g., ADF)"
    }
  • Response:
    {
      "status": "Page updated and tracked",
      "page_id": "622593",
      "new_version": 3
    }
  • Error Responses:
    • 400 Bad Request: If agent_id, title, or content is missing in the request body.
    • 404 Not Found: If the agent_id does not correspond to a registered agent.
    • 500 Internal Server Error: For Confluence API errors during fetch or update operations.

7. POST /api/confluence/revert_page/{change_id}

  • Description: Reverts a previously tracked change on a Confluence page. It identifies the page and the target version (the state before the tracked change) from the change_id. The MCP server uses the credentials of the agent that made the original change (or a default admin agent if configured) to restore the page to that specific version via the Confluence API.
  • Path Parameters:
    • change_id (string): The unique identifier of the tracked change to revert.
  • Response:
    {
      "status": "Page 622593 reverted to version 2",
      "new_version": 4
    }
  • Error Responses:
    • 404 Not Found: If the change_id does not correspond to any tracked change, or if the agent associated with the change is not found.
    • 500 Internal Server Error: For Confluence API errors during the restore operation.