Model Context Protocolを試す 2024/11/30
from 2024/11/30
Model Context Protocol
Quickstart - Model Context Protocol
【Model Context Protocol】Claudeが全てのアプリと繋がる!?SlackやGitHubと連携してみた | WEEL
https://gyazo.com/2149ff8447339eeb886d537d3cbc10cd
クイックスタート:SQLiteと連携
https://gyazo.com/831ae51a1a733db742105ef5496ff0bb
Set up a local SQLite database
Connect Claude Desktop to it through MCP
Query and analyze your data securely
Claude Desktopを入れる
Prerequisites
macOSとWindowsがある
WSLは使えない?yosider.icon
まあ一旦Windowsでやるか
uv
git
もう入ってたのでスルー
sqlite
Installation
Create a sample database
なぜかホームディレクトリに.dbを作るコマンドになっている、気持ち悪いので別ディレクトリにする
Configure Claude Desktop
code:%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"sqlite": {
"command": "uvx",
"args": [
"mcp-server-sqlite",
"--db-path",
"C:\\Users\\YOUR_USERNAME\\test.db"
]
}
}
}
dbのパスを上で作ったものにする
Test it out
Claude Desktopを再起動してデータベースの中身を聞いてみる
繋がらない…yosider.icon
バツボタン押してもタスクバーに常駐していた!再起動するにはそっちをQuitする必要がある
いけた
クエリなどのたびにいちいち許可を求めてくる、うーん
GitHubと連携
トークンを準備
個人用アクセス トークンを管理する - GitHub Docs
fine-grained personal access token
GitHub推奨
リポジトリごと
personal access token (classic)
全リポジトリ
こっちが必要なようだ
setup | servers/src/github at main · modelcontextprotocol/serversでこっちにリンクされている
その下の説明
Select which repositories you'd like this token to have access to (Public, All, or Select)
これはfine-grained??
Create a token with the repo scope ("Full control of private repositories")
これはclassicにしかない
repo権限を与える
Node.jsをインストール
公式サイトによるとfnmというのを使う?
chocolateyを使う版もある
こっちにした
設定
code:claude_desktop_config.json
{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
Windowsではnpxがうまくいかない?
MCP servers fail to connect with npx on Windows · Issue #40 · modelcontextprotocol/servers
$ npm install -g @modelcontextprotocol/server-github
code:json
{
"mcpServers": {
"filesystem": {
"command": "node",
"args": [
"C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-github\\dist\\index.js"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "..."
}
}
}
}
これでいけた
なにをしよう…
Cosenseのserverをつくる?