MCP で接続する
この記事の内容
MCP でできること
MCP
できない
接続先
接続先のhttps://api.<サービスのドメイン>/mcp です。
https://api.kumidana.com/mcpPOST だけを
接続方法を選ぶ
接続の
OAuth で接続する
OAuth に
- クライアントに
MCP サーバーと して https://api.kumidana.com/mcpを登録します。 - クライアントが
認証を 始めると、 ブラウザで 管理画面の 「アクセスの 許可」 画面が 開きます。 - アプリ名と
戻り先を 確かめ、 サイトと 範囲の 組み合わせ ( 「MCP」か 「MCP (公開も)」)を 選びます。 - 「許可」を
押し、 パスキーで 本人確認を します。
許可の
アクセストークンの
な
個人アクセストークンで接続する
OAuth に
- 管理画面の
/admin/account/tokens(左メニューの一番下の 自分の 名前を 押して アカウント画面を 開き、 「個人アクセストークン」)を 開きます。 - 名前を
入れ、 範囲を 「MCP」か 「MCP (公開も)」に して 「作成」を 押します。 - 表示された
トークン ( kmd_pat_で始まります)を コピーします。 画面に 出るのは この 1 回だけで、 後からは 見られません。
範囲ごとに
| 範囲 | できる |
|---|---|
| MCP | 読み取り、 |
| MCP |
上に |
範囲をentry:read、entry:publish を
Git 用の
呼び出しの回数の上限
MCP のAuthorization を
クライアントの設定例
Claude Code
OAuth で
claude mcp add --transport http kumidana https://api.kumidana.com/mcp登録後は、/mcp から
個人アクセストークンで--header でAuthorization ヘッダーを
claude mcp add --transport http kumidana https://api.kumidana.com/mcp \
--header "Authorization: Bearer kmd_pat_xxxxxxxx"トークンが
Claude Desktop とその他のクライアント
mcpServers を
{
"mcpServers": {
"kumidana": {
"type": "http",
"url": "https://api.kumidana.com/mcp",
"headers": { "Authorization": "Bearer kmd_pat_xxxxxxxx" }
}
}
}OAuth にheaders をurl だけを
クライアントを作る人向け: OAuth の探索と登録
自作の
- 認証なしで
POST https://api.kumidana.com/mcpを呼ぶと、 401 が 返ります。 WWW-AuthenticateにBearer resource_metadata="https://api.kumidana.com/.well-known/oauth-protected-resource"が入っています。 - その
URL を GET すると、 保護された リソースの メタデータが 返ります。 resourceはhttps://api.kumidana.com/mcp、authorization_serversはhttps://admin.kumidana.com、scopes_supportedはmcpとmcp-publishです。/.well-known/oauth-protected-resource/mcpの形でも 返ります。 https://admin.kumidana.com/.well-known/oauth-authorization-serverをGET すると、 認可サーバーの メタデータが 返ります。
認可サーバーの
| キー | 値 |
|---|---|
issuer |
https://admin.kumidana.com |
authorization_endpoint |
https://admin.kumidana.com/oauth/authorize |
token_endpoint |
https://admin.kumidana.com/oauth/token |
registration_endpoint |
https://admin.kumidana.com/oauth/register |
revocation_endpoint |
https://admin.kumidana.com/oauth/revoke |
device_authorization_endpoint |
https://admin.kumidana.com/oauth/device/code |
response_types_supported |
code |
grant_types_supported |
authorization_code、refresh_token、urn:ietf:params:oauth:grant-type:device_code |
code_challenge_methods_supported |
S256(PKCE は |
token_endpoint_auth_methods_supported |
none(公開クライアントだけ。 |
scopes_supported |
read、write、mcp、mcp-publish |
authorization_response_iss_parameter_supported |
true(戻り先にiss が |
MCP にmcp(読み取りとmcp-publish(公開とread とwrite は
動的クライアント登録
クライアントは、POST https://admin.kumidana.com/oauth/register に
curl -X POST https://admin.kumidana.com/oauth/register \
-H "Content-Type: application/json" \
-d '{"client_name":"My MCP Client","redirect_uris":["http://127.0.0.1:8123/callback"],"token_endpoint_auth_method":"none"}'redirect_urisは1〜5 個です。 httpsのURI か、 ループバック ( localhostや127.0.0.1)のhttpのURI だけが 使えます。 token_endpoint_auth_methodはnoneだけで、省略も できます。 - 本文は
8KB までです。 client_nameは100 文字までです。 省くと 「MCP クライアント」に なります。 - 成功すると
201 で、 client_id、client_name、redirect_uris、grant_types、response_typesなどが返ります。 - 登録できる
数には 上限が あり、 超えると 503 ( temporarily_unavailable)です。 - 登録の
回数は IP ごとに 30 回 / 60 秒です ( /oauth/token、/oauth/device/codeと合わせて 数えます)。
登録した
認可、トークン、取り消し
認可コード + PKCE でauthorization_endpoint にresponse_type=code、client_id、redirect_uri、code_challenge、code_challenge_method=S256、scope、state をresource にhttps://api.kumidana.com/mcp をresource がinvalid_target です。
POST /oauth/token に、application/x-www-form-urlencoded でgrant_type=authorization_code、code、redirect_uri、code_verifier、client_id をkmd_oat_、kmd_ort_、grant_type=refresh_token で{ "error": "invalid_grant", "error_description": "…" } の
POST /oauth/revoke にtoken とclient_id を
デバイスフロー
メタデータにはgrant_types はauthorization_code とrefresh_token だけです。unauthorized_client(
権限の決まり
AI が
- 公開・取り下げ・種類の
定義の 変更には、 範囲が 「MCP (公開も)」である ことが 必要です。 足りないと 「この 操作には トークンの 範囲に 「公開」が 必要です」と 返ります。 - 持ち主が
メンバーから 外れた とき、 停止された とき、 サイトが 停止された ときは、 トークンが すぐに 使えなくなります。 - 無効な
トークンには 401 が 返ります。 - ブラウザからの
呼び出し ( Originヘッダー付き)は、403 「ブラウザからは 使えません」で 断ります。 ウェブページ上の スクリプトから MCP は 使えません。
MCP 経由のentry.save-draft、entry.publish など)で
安全に使うために
AI に
トークンは、