{
  "openapi": "3.1.0",
  "info": {
    "title": "账小秘智能体记账 API",
    "version": "0.2.0"
  },
  "servers": [
    {
      "url": "https://mcp.squirrelly.ai"
    }
  ],
  "paths": {
    "/agent/v1/account": {
      "get": {
        "operationId": "getAccount",
        "security": [
          {
            "oauth": [
              "account:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful result; create requires status=committed"
          },
          "401": {
            "description": "Authorization required"
          },
          "403": {
            "description": "Scope, account or book denied"
          },
          "422": {
            "description": "Invalid structured input"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "503": {
            "description": "Service unavailable"
          }
        }
      }
    },
    "/agent/v1/books": {
      "get": {
        "operationId": "listBooks",
        "security": [
          {
            "oauth": [
              "books:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful result; create requires status=committed"
          },
          "401": {
            "description": "Authorization required"
          },
          "403": {
            "description": "Scope, account or book denied"
          },
          "422": {
            "description": "Invalid structured input"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "503": {
            "description": "Service unavailable"
          }
        }
      }
    },
    "/agent/v1/transactions": {
      "post": {
        "operationId": "createTransaction",
        "security": [
          {
            "oauth": [
              "transactions:create"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful result; create requires status=committed"
          },
          "401": {
            "description": "Authorization required"
          },
          "403": {
            "description": "Scope, account or book denied"
          },
          "422": {
            "description": "Invalid structured input"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "503": {
            "description": "Service unavailable"
          },
          "202": {
            "description": "Unknown write outcome; preserve operationId and retry with SAME key"
          },
          "409": {
            "description": "Same key used with different content"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "amountMinor",
                  "currency",
                  "description",
                  "occurredOn"
                ],
                "properties": {
                  "kind": {
                    "enum": [
                      "income",
                      "expense"
                    ]
                  },
                  "amountMinor": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000000000000
                  },
                  "currency": {
                    "type": "string",
                    "description": "ISO 4217 code accepted by account service"
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "occurredOn": {
                    "type": "string",
                    "format": "date"
                  },
                  "categoryId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "subcategoryId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listTransactions",
        "security": [
          {
            "oauth": [
              "transactions:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful result; create requires status=committed"
          },
          "401": {
            "description": "Authorization required"
          },
          "403": {
            "description": "Scope, account or book denied"
          },
          "422": {
            "description": "Invalid structured input"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "enum": [
                "income",
                "expense"
              ]
            }
          }
        ]
      }
    },
    "/agent/v1/summaries": {
      "get": {
        "operationId": "summarizeTransactions",
        "security": [
          {
            "oauth": [
              "summaries:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful result; create requires status=committed"
          },
          "401": {
            "description": "Authorization required"
          },
          "403": {
            "description": "Scope, account or book denied"
          },
          "422": {
            "description": "Invalid structured input"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/agent/v1/operations/{operationId}": {
      "get": {
        "operationId": "getOperation",
        "security": [
          {
            "oauth": [
              "transactions:create"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful result; create requires status=committed"
          },
          "401": {
            "description": "Authorization required"
          },
          "403": {
            "description": "Scope, account or book denied"
          },
          "422": {
            "description": "Invalid structured input"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "parameters": [
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://mcp.squirrelly.ai/oauth/authorize",
            "tokenUrl": "https://mcp.squirrelly.ai/oauth/token",
            "scopes": {
              "account:read": "account:read",
              "books:read": "books:read",
              "transactions:read": "transactions:read",
              "transactions:create": "transactions:create",
              "summaries:read": "summaries:read"
            }
          }
        }
      }
    }
  }
}
