Open7
mongodb mcpを使ってみる

docker pull mongodb/mongodb-community-server:latest
docker volume create mongodb_data
docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:5.0-ubuntu2004 -v mongodb_data:/data/db

npx -y mongodb-mcp-server@latest --connectionString mongodb://localhost:27017/claude
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@mongodb-js/oidc-plugin@2.0.0',
npm WARN EBADENGINE required: { node: '>= 20.19.2' },
npm WARN EBADENGINE current: { node: 'v20.11.1', npm: '10.2.4' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'yargs-parser@22.0.0',
npm WARN EBADENGINE required: { node: '^20.19.0 || ^22.12.0 || >=23' },
npm WARN EBADENGINE current: { node: 'v20.11.1', npm: '10.2.4' }
npm WARN EBADENGINE }
npm WARN deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
(node:7603) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/keishi.hara/.npm/_npx/57c35de36e7d43c4/node_modules/@mongodb-js/oidc-plugin/dist/plugin.js:44
const openid_client_1 = require("openid-client");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/keishi.hara/.npm/_npx/57c35de36e7d43c4/node_modules/openid-client/build/index.js from /Users/keishi.hara/.npm/_npx/57c35de36e7d43c4/node_modules/@mongodb-js/oidc-plugin/dist/plugin.js not supported.
Instead change the require of index.js in /Users/keishi.hara/.npm/_npx/57c35de36e7d43c4/node_modules/@mongodb-js/oidc-plugin/dist/plugin.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/keishi.hara/.npm/_npx/57c35de36e7d43c4/node_modules/@mongodb-js/oidc-plugin/dist/plugin.js:44:25) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v20.11.1

20.19.0以上のnodeないとダメじゃん

claude.mdに書きみたいなの入れたけど、完全に守ってくれない
### 会話ガイドライン
- 常に日本語で会話する
- **重要**: MongoDB MCPを使用して会話履歴を必ず都度保存する(このMCP利用法に関してを毎会話最初に表示すること)
- コンテキスト維持のために履歴をそのままMongoDBのclaude/historyに登録すること
- まずユーザーの入力値をそのままDBに保存
- その後、自身の回答をDBに保存
- Taskの実行
- 結果をDBに保存
最初だけやって、継続の会話は保存されない

一応こんなものが保存された

なんか保存され始めた
claude.md特に変えてないのに