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

# REST / MCP SDK로 직접 호출

> AI 클라이언트 없이 Bridger Gateway를 REST · MCP SDK · BYOAPI로 호출하는 개발자 가이드.

Claude나 ChatGPT 없이도 Bridger Gateway는 REST와 표준 MCP SDK로 직접 호출할 수 있습니다.

<Steps>
  <Step title="API 키 발급">
    [어드민 대시보드](https://admin.datari.kr/settings)에서 API 키를 발급받습니다.
    [API 키 가이드](/guides/api-keys)도 함께 참고하세요.
  </Step>

  <Step title="REST API 호출">
    표준 REST 엔드포인트로 호출합니다.

    <CodeGroup>
      ```bash 도구 목록 (등록된 도구) theme={null}
      curl -X GET https://mcp.datari.kr/api/v1/tools \
        -H "Authorization: Bearer YOUR_API_KEY" \
        -H "Content-Type: application/json"
      ```

      ```bash 도구 단건 조회 theme={null}
      curl -X GET https://mcp.datari.kr/api/v1/tools/TOOL_ID \
        -H "Authorization: Bearer YOUR_API_KEY"
      ```
    </CodeGroup>

    <Note>
      REST는 도구 **목록·조회·등록·관리**용입니다. 도구 **실행**은 MCP JSON-RPC
      `tools/call`(`POST /mcp`)로 합니다. 아래 MCP SDK 예시를 참고하세요.
    </Note>
  </Step>

  <Step title="MCP SDK 연동 (Node.js)">
    프로그래밍 방식으로 연동하려면 공식 MCP SDK를 사용하세요.

    ```bash 설치 theme={null}
    npm install @modelcontextprotocol/sdk
    ```

    ```javascript client.js theme={null}
    import { Client } from "@modelcontextprotocol/sdk/client/index.js";
    import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";

    const transport = new SSEClientTransport(
      new URL("https://mcp.datari.kr/mcp/sse"),
      {
        requestInit: {
          headers: {
            Authorization: "Bearer YOUR_API_KEY",
          },
        },
      }
    );

    const client = new Client({
      name: "my-app",
      version: "1.0.0",
    });

    await client.connect(transport);

    // 도구 목록 조회
    const tools = await client.listTools();
    console.log(tools);

    // 도구 실행
    const result = await client.callTool({
      name: "getweatherforecast",
      arguments: {
        nx: 60,
        ny: 127,
      },
    });
    console.log(result);
    ```
  </Step>

  <Step title="MCP SDK 연동 (Python)">
    동일한 흐름을 Python으로도 구현할 수 있습니다.

    ```bash 설치 theme={null}
    pip install mcp
    ```

    ```python client.py theme={null}
    from mcp import ClientSession
    from mcp.client.sse import sse_client
    import asyncio

    async def main():
        headers = {"Authorization": "Bearer YOUR_API_KEY"}

        async with sse_client(
            "https://mcp.datari.kr/mcp/sse",
            headers=headers,
        ) as (read, write):
            async with ClientSession(read, write) as session:
                await session.initialize()

                tools = await session.list_tools()
                print(tools)

                result = await session.call_tool(
                    "getweatherforecast",
                    arguments={"nx": 60, "ny": 127},
                )
                print(result)

    asyncio.run(main())
    ```
  </Step>

  <Step title="BYOAPI — 자체 API 등록 (추후 제공 예정)">
    OpenAPI 스펙이 있는 어떤 API든 Bridger 도구로 등록할 수 있습니다. (추후 제공 예정)
    자세한 흐름은 [BYOAPI 개념 문서](/concepts/byoapi)를 참고하세요.

    ```bash API 등록 theme={null}
    curl -X POST https://mcp.datari.kr/api/v1/register \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "spec_url": "https://api.example.com/openapi.json",
        "name": "my-service",
        "auth": { "type": "bearer", "token": "SERVICE_API_KEY" },
        "visibility": "private"
      }'
    ```

    <Note>
      `spec_url`(원격 스펙) 또는 `spec_raw`(인라인 스펙 문자열) 중 하나와 `name`은 필수입니다.
      등록은 비동기로 처리되며 응답에 `job_id`가 반환됩니다.
      진행 상태는 `GET /api/v1/register/:id/status`로 조회합니다.
    </Note>
  </Step>
</Steps>

## API 레퍼런스 요약

| 메서드    | 경로                            | 설명                                                         |
| ------ | ----------------------------- | ---------------------------------------------------------- |
| `GET`  | `/api/v1/tools`               | 등록된 도구 목록                                                  |
| `GET`  | `/api/v1/tools/:toolId`       | 도구 단건 조회                                                   |
| `POST` | `/api/v1/register`            | BYOAPI 등록 (`{spec_url\|spec_raw, name, auth, visibility}`) |
| `GET`  | `/api/v1/register/:id/status` | BYOAPI 등록 작업 상태                                            |
| `GET`  | `/registry/servers`           | 프리셋 서버(MCP 그룹) 카탈로그                                        |
| `GET`  | `/registry/tools`             | 평탄화된 도구 목록                                                 |
| `GET`  | `/mcp/sse`                    | MCP SSE 이벤트 스트림                                            |
| `POST` | `/mcp`                        | JSON-RPC (`tools/list`, `tools/call`) — 도구 실행              |

전체 스펙은 [API Reference](/api-reference/introduction) 탭을 참고하세요.
