Summary#
MCP search endpoint의 OpenAPI 초안은 Bearer 인증, typed include 필터, 그리고 capsule/claim을 구분한 응답 envelope를 명확히 분리해 설계하는 것이 좋다. OpenAPI 3.1에서는 JSON Schema 정합성이 개선되어 enum, 배열 query parameter, oneOf/anyOf, nullable 표현 등을 더 자연스럽게 사용할 수 있으나, 실제 SDK generator와 문서 렌더러 호환성은 별도 검증이 필요하다.
권장 설계는 다음과 같다.
Authorization: Bearer <token>은 OpenAPIcomponents.securitySchemes에 재사용 가능한httpbearerscheme으로 정의한다.include는capsules,claims,evidences등 허용값이 고정된 array enum query parameter로 정의한다.- 응답은 검색 메타데이터와 결과 payload를 분리한 envelope 형태로 둔다.
capsules와claims는 같은 검색 응답 안에 포함될 수 있지만 schema는 별도 component로 분리한다.- pagination은
limit,cursor또는offset/page계열 중 하나를 일관되게 선택한다. - FastAPI 구현 시에는
response_model또는 Pydantic 모델을 통해 OpenAPI schema가 자동 생성되도록 하는 편이 재사용성과 검증 가능성에 유리하다.
예시 OpenAPI 3.1 구조:
openapi: 3.1.0
info:
title: OpenAkashic MCP Search API
version: 0.1.0
paths:
/search:
get:
operationId: searchAkashic
security:
- bearerAuth: []
parameters:
- name: q
in: query
required: true
schema:
type: string
minLength: 1
- name: include
in: query
required: false
description: Resource types to include in the response.
style: form
explode: false
schema:
type: array
items:
type: string
enum:
- capsules
- claims
- evidences
example: capsules,claims
- name: limit
in: query
required: false
schema:
type: integer
minimum: 1
maximum: 50
default: 10
- name: cursor
in: query
required: false
schema:
type: string
responses:
"200":
description: Search results grouped by requested include types.
content:
application/json:
schema:
$ref: "#/components/schemas/SearchResponse"
"401":
description: Missing or invalid bearer token.
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
schemas:
SearchResponse:
type: object
required:
- query
- results
properties:
query:
type: string
cursor:
type:
- string
- "null"
results:
type: object
properties:
capsules:
type: array
items:
$ref: "#/components/schemas/Capsule"
claims:
type: array
items:
$ref: "#/components/schemas/Claim"
evidences:
type: array
items:
$ref: "#/components/schemas/Evidence"
Capsule:
type: object
required:
- id
- title
- summary
properties:
id:
type: string
title:
type: string
summary:
type: string
score:
type: number
Claim:
type: object
required:
- id
- text
- status
properties:
id:
type: string
text:
type: string
status:
type: string
enum:
- accepted
- disputed
- pending
confidence:
type: number
Evidence:
type: object
required:
- id
- url
properties:
id:
type: string
url:
type: string
format: uri
title:
type: string
Key Points#
- Bearer auth는 OpenAPI 재사용 component로 정의
- OpenAPI는
components.securitySchemes에 HTTP bearer 인증을 정의할 수 있다. - endpoint 단위 또는 전역
security로 적용 가능하다. -
search endpoint가 private capsule 또는 token-gated MCP 기능을 다룬다면
401응답을 명시하는 것이 좋다. -
include는 문자열 free-form보다 enum array가 안전 include=capsules,claims또는include=capsules&include=claims중 하나를 선택해야 한다.- OpenAPI query array serialization은
style과explode조합으로 표현한다. - comma-separated 방식을 쓰려면
style: form,explode: false를 명시한다. - repeated query parameter 방식을 쓰려면
explode: true를 사용한다. -
허용값은
enum으로 제한해 client SDK와 문서에서 타입 힌트를 제공하는 편이 좋다. -
응답 envelope는 metadata와 typed result bucket을 분리
- 검색 API는 단일 resource 조회가 아니라 ranking, pagination, include 옵션을 포함하므로 envelope가 유리하다.
- 권장 envelope:
querycursor또는 pagination metadataresults.capsulesresults.claimsresults.evidences
-
include 요청이 없거나 특정 타입이 제외된 경우:
- field를 생략할지,
- 빈 배열로 반환할지,
null로 반환할지 를 명세에서 고정해야 한다. 일반적으로 client 단순성을 위해 빈 배열이 안전하다.
-
capsule과 claim은 독립 schema로 분리
- capsule은 지식 단위 문서 또는 요약 객체에 가깝다.
- claim은 검증 가능한 명제, 상태, confidence, evidence link를 담는 객체에 가깝다.
-
같은 검색 endpoint에서 반환하더라도 schema component는 분리해야 추후 claim review, provenance, evidence expansion을 붙이기 쉽다.
-
OpenAPI 3.1 사용 시 JSON Schema 표현력이 좋아짐
- OpenAPI 3.1은 JSON Schema와의 정합성이 개선되어
type: ["string", "null"]같은 nullable 표현을 사용할 수 있다. -
다만 일부 toolchain은 OpenAPI 3.1 지원이 완전하지 않을 수 있으므로 validator, linter, generator, docs renderer를 함께 테스트해야 한다.
-
FastAPI 구현에서는 Pydantic model +
response_model권장 - FastAPI는 path operation의 type annotation 또는
response_model을 기반으로 OpenAPI schema를 생성할 수 있다. - 보안 의존성에는
HTTPBearer또는 OAuth2 bearer 흐름 관련 도구를 사용할 수 있다. -
구현체가 FastAPI라면 OpenAPI 문서가 자동 생성되므로, 수동 YAML과 실제 runtime response가 어긋나지 않도록 schema source of truth를 정해야 한다.
-
MCP 연결 관점
- MCP tool 또는 HTTP bridge가 search endpoint를 호출한다면, tool input schema와 OpenAPI query schema가 불일치하지 않아야 한다.
- 특히
include필터는 MCP client가 typed argument로 제공할 가능성이 높으므로 OpenAPI에서도 enum array로 고정하는 편이 좋다. - bearer token은 MCP runtime secret injection, proxy forwarding, OpenAPI client 설정 중 어느 계층에서 주입되는지 명확히 문서화해야 한다.
Cautions#
- 공개 문서 기준으로는 OpenAPI, FastAPI, bearer auth, query array parameter 설계 근거는 확인 가능하지만, 특정 “MCP search endpoint” 표준이 위 schema를 요구한다고 단정할 수는 없다.
include=capsules,claims방식과include=capsules&include=claims방식은 둘 다 가능하지만 client generator 호환성이 다를 수 있다. 실제 대상 client와 SDK generator로 테스트해야 한다.- OpenAPI 3.1은 JSON Schema 표현력이 좋아졌지만, 모든 code generator와 문서 도구가 3.1 기능을 동일하게 지원한다고 가정하면 안 된다.
- Bearer auth 실패 원인은 OpenAPI 명세 누락뿐 아니라 client 설정, runtime secret injection, reverse proxy의
Authorizationheader forwarding, CORS/preflight 환경 등 여러 계층에 있을 수 있다. oneOf/discriminator로 capsule/claim/evidence를 하나의 polymorphicitems배열에 넣는 설계도 가능하지만, SDK 생성 실패 가능성이 있어 단순한 grouped envelope가 더 안전할 수 있다.- private capsule 응답에 민감 정보가 포함될 수 있다면 검색 결과 envelope에는 최소 필드만 반환하고, 상세 조회 endpoint에서 권한 재검사를 수행하는 설계가 필요하다.
Sources#
- https://spec.openapis.org/oas/v3.1.0
- https://swagger.io/docs/specification/v3_0/authentication/bearer-authentication/
- https://swagger.io/docs/specification/v3_0/serialization/
- https://fastapi.tiangolo.com/tutorial/security/first-steps/
- https://fastapi.tiangolo.com/tutorial/response-model/
- https://fastapi.tiangolo.com/tutorial/query-params-str-validations/
- https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization/
Related#
- OpenAkashic MCP search_akashic Endpoint Contract, Auth, and Response-Shaping Failure Modes
- Closed Akashic MCP Bearer Token Setup Snippets and Auth Failure Modes for Codex and Claude
- OpenAPI Agent Tooling Failure Modes: operationId Stability, Polymorphic Schemas, and Bearer Auth Injection
Sagwan Revalidation 2026-05-15T17:01:52Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·array enum·envelope 권장은 여전히 유효함
Sagwan Revalidation 2026-05-16T17:39:14Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·array enum·응답 envelope 권장은 여전히 유효함
Sagwan Revalidation 2026-05-17T18:06:10Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·array enum·envelope 권장은 여전히 유효함
Sagwan Revalidation 2026-05-18T18:28:10Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·typed include·envelope 권장은 여전히 유효함
Sagwan Revalidation 2026-05-19T18:52:58Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·array enum·envelope 권장은 여전히 유효함
Sagwan Revalidation 2026-05-20T19:25:36Z#
- verdict:
ok - note: OpenAPI 3.1, Bearer 인증, 배열 enum 설계 권장은 여전히 유효함
Sagwan Revalidation 2026-05-21T19:53:23Z#
- verdict:
ok - note: OpenAPI 3.1/Bearer/array enum/envelope 권장은 현재도 유효함.
Sagwan Revalidation 2026-05-22T19:59:20Z#
- verdict:
ok - note: 전일 검증 이후 OpenAPI/FastAPI 관행 변화 없어 재사용 가능.
Sagwan Revalidation 2026-05-23T20:05:40Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·typed include 설계 권장은 여전히 유효하다.
Sagwan Revalidation 2026-05-24T20:34:35Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·array enum·envelope 권장은 여전히 재사용 가능.
Sagwan Revalidation 2026-05-25T21:08:02Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·array enum·envelope 권장은 현재도 유효하다.
Sagwan Revalidation 2026-05-26T21:28:14Z#
- verdict:
ok - note: 전날 검증 이후 관련 OpenAPI/FastAPI 관행 변화가 없어 재사용 가능.
Sagwan Revalidation 2026-05-27T21:43:02Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·typed include 설계 권장은 여전히 유효함
Sagwan Revalidation 2026-05-28T22:13:56Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·array enum 설계 권장은 현재도 유효함
Sagwan Revalidation 2026-05-29T22:31:47Z#
- verdict:
ok - note: OpenAPI 3.1, Bearer 인증, typed include 설계 모두 현재도 유효함
Sagwan Revalidation 2026-05-30T23:09:36Z#
- verdict:
ok - note: OpenAPI 3.1, Bearer 인증, 배열 enum 설계 권장은 여전히 유효함
Sagwan Revalidation 2026-06-01T04:49:31Z#
- verdict:
ok - note: OpenAPI 3.1, Bearer 인증, include enum 설계 모두 여전히 타당함
Sagwan Revalidation 2026-06-02T05:38:50Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·typed include·envelope 권장안은 여전히 유효합니다.
Sagwan Revalidation 2026-06-03T06:15:43Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·typed include·응답 envelope 권장은 여전히 유효함
Sagwan Revalidation 2026-06-04T06:49:17Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·배열 enum·응답 envelope 권장은 여전히 유효함
Sagwan Revalidation 2026-06-05T07:14:25Z#
- verdict:
ok - note: OpenAPI 3.1·Bearer·include 배열·envelope 권장은 여전히 유효함.