API 키 받기
/login → Google 또는 GitHub 로그인. 첫 로그인 시 가상 API 키 (sk-...) 자동 발급. 신규 계정은 잔액 $0부터 — 셀프 서비스 충전 곧 지원.
curl (streamable-http 트랜스포트)
단계 1: initialize 후 mcp-session-id 응답 헤더에서 session id 캡처
text
curl -i -X POST https://api.twinkleai.tw/mcp/ \
-H "Authorization: Bearer sk-..." \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'단계 2: tools/call
text
curl -X POST https://api.twinkleai.tw/mcp/ \
-H "Authorization: Bearer sk-..." \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-H "mcp-session-id: <from-step-1>" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"opendata-list_domains","arguments":{}}}'응답은 SSE 스타일 프레이밍 — data:로 시작하는 마지막 줄을 찾아 JSON 파싱.
Python (fastmcp)
python
import asyncio
from fastmcp.client import Client
from fastmcp.client.auth import BearerAuth
async def main():
async with Client(
"https://api.twinkleai.tw/mcp/",
auth=BearerAuth("sk-..."),
) as client:
tools = await client.list_tools()
print([t.name for t in tools])
r = await client.call_tool(
"opendata-search_datasets",
{"query": "AQI", "domain": "environment", "limit": 5},
)
# response 在 r.content[0].text — JSON string
import json
print(json.loads(r.content[0].text))
asyncio.run(main())도구는 CallToolResult.content[0].text를 JSON 문자열로 반환. 라이선스, 인용, 기타 메타데이터는 _meta 필드로 투과.
도구 레퍼런스
| 도구 | 인자 | 반환 값 (간략) |
|---|---|---|
| opendata-list_domains | — | [{key, name_zh, scope, typical_questions}] |
| opendata-search_datasets | {query, domain?, limit?} | [{dataset_id, title, score, license}] |
| opendata-get_dataset | {dataset_id} | {schema, columns, license, source_url} |
| opendata-query_rows | {dataset_id, where?, limit?} | [row, ...] |
| opendata-materialize_dataset | {dataset_id, format?} | 全表 CSV / JSON |
전체 스키마는 tools/list를 통해 — JSON Schema로 자동 생성.
인증
- Bearer 토큰 — 헤더
Authorization: Bearer sk-.... Twinkle Hub 발행 가상 키, 사용자당 1 개. /dashboard에서 받으세요. - OAuth 플로우 없음 — PKCE / 리프레시 토큰 불필요; 장기 bearer 하나.
- 레이트 제한 — 현재 키당 RPM/TPM 제한 없음; max_budget만 적용 (spend > max_budget 시 게이트웨이 거부).
요금
곧 제공
알파 기간 동안 모든 도구 무료. 과금 시작 전 도구별 가격을 공지하고, 기존 사용자에게 전환 할인 기간을 제공합니다.
알파 기간 무료. spend 추적 파이프라인은 동작 (5〜15 초 비동기 지연, 게이트웨이는 DB 쓰기를 배치); 과금 시작 후 쿼터 적용은 다음 요청에서 실시간 적용.