0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自作MCPサーバー その7

0
Last updated at Posted at 2026-11-11

概要

MCPサーバーが気になったので、調べてみた。
AIに聞いた。
サンプルやってみた。
Desktop-Commanderやってみた。
c#を、コンパイルしてみた。

claude_desktop_config.jsonに、mcpServers を追加する。

エラーが出た。

image.png

npxで、desktop-commanderをインストール

エラーが出た

>npx -y @wonderwhy-er/desktop-commander@latest
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE   package: '@wonderwhy-er/desktop-commander@0.3.2',
npm warn EBADENGINE   required: { node: '>=22.12.0' },
npm warn EBADENGINE   current: { node: 'v22.11.0', npm: '10.9.0' }
npm warn EBADENGINE }
npm warn deprecated uuid@8.3.2: uuid@10 and below is no longer supported.  For ESM codebases, update to uuid@latest.  For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).
npm warn deprecated glob@10.5.0: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
node:internal/modules/cjs/loader:1249
  const err = new Error(message);
              ^

Error: Cannot find module './lib/retry'
Require stack:
- C:\Users\ohisa\AppData\Local\npm-cache\_npx\4b4c857f6efdfb61\node_modules\retry\index.js
- C:\Users\ohisa\AppData\Local\npm-cache\_npx\4b4c857f6efdfb61\node_modules\proper-lockfile\lib\lockfile.js
- C:\Users\ohisa\AppData\Local\npm-cache\_npx\4b4c857f6efdfb61\node_modules\proper-lockfile\index.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)
    at Function._load (node:internal/modules/cjs/loader:1075:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Module.require (node:internal/modules/cjs/loader:1340:12)
    at require (node:internal/modules/helpers:141:16)
    at Object.<anonymous> (C:\Users\ohisa\AppData\Local\npm-cache\_npx\4b4c857f6efdfb61\node_modules\retry\index.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Object..js (node:internal/modules/cjs/loader:1689:10)
    at Module.load (node:internal/modules/cjs/loader:1318:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\ohisa\\AppData\\Local\\npm-cache\\_npx\\4b4c857f6efdfb61\\node_modules\\retry\\index.js',
    'C:\\Users\\ohisa\\AppData\\Local\\npm-cache\\_npx\\4b4c857f6efdfb61\\node_modules\\proper-lockfile\\lib\\lockfile.js',
    'C:\\Users\\ohisa\\AppData\\Local\\npm-cache\\_npx\\4b4c857f6efdfb61\\node_modules\\proper-lockfile\\index.js'
  ]
}

Node.js v22.11.0

node.jsのバージョンを上げる。

>nvm install lts
Downloading node.js version 26.13.0 (64-bit)...
Extracting node and npm...
Complete
Installation complete.
If you want to use this version, type:

nvm use 26.13.0

>nvm use 26.13.0

再度、npxで、desktop-commanderをインストール

>npx @wonderwhy-er/desktop-commander@latest setup


??????? ???????????????????  ???????????? ??????? ???????     ??????? ??????? ????   ????????   ???? ?????? ????   ?????????? ???????????????
??????????????????????????? ??????????????????????????????   ?????????????????????? ?????????? ??????????????????  ???????????????????????????
???  ?????????  ???????????????    ???   ???   ???????????   ???     ???   ??????????????????????????????????????? ??????  ?????????  ????????
???  ?????????  ???????????????    ???   ???   ??????????    ???     ???   ??????????????????????????????????????????????  ?????????  ????????
???????????????????????????  ???   ???   ????????????        ???????????????????? ??? ?????? ??? ??????  ?????? ?????????????????????????  ???
??????? ???????????????????  ???   ???    ??????? ???         ??????? ??????? ???     ??????     ??????  ??????  ???????????? ???????????  ???


Creating config directory: C:\Users\ohisa\AppData\Roaming\Claude
Claude config file not found at: C:\Users\ohisa\AppData\Roaming\Claude\claude_desktop_config.json
Creating default config file...
Default config file created.
? Desktop Commander MCP vunknown successfully added to Claude’s configuration.
Configuration location: C:\Users\ohisa\AppData\Roaming\Claude\claude_desktop_config.json
Windows: Claude restart skipped - requires manual restart

? Installation successfully completed! Thank you for using Desktop Commander!


The server is available as "desktop-commander" in Claude's MCP server list
Future updates will install automatically ? no need to run this setup again.


? Need help or have feedback? Happy to jump on a quick call:


https://calendar.app.google/SHMNZN5MJznJWC5A7


or join our community: https://discord.com/invite/kQ27sNnZr7



Desktop-Commanderを使って、hello.csを作ってcscでコンパイル・実行する手順。

デスクトップコマンダーは、使えませんか

使えるか確認します。

読み込めたので、実際に動くか設定を取得して確認します。

はい、使えます。先ほどの私の回答は不十分でした。Desktop Commanderが接続されているので、あなた自身のWindows PCを操作できます。今、設定を取得して接続を確認しました。

確認できた環境

  • OS: Windows(デフォルトシェルはPowerShell)
  • Node.js: あり(v26.13.0)
  • Python: 検出されず(未インストールか、PATHに通っていない可能性があります)

Desktop Commanderでできること

  • PC上のコマンド実行(PowerShellなど)
  • ファイルの読み書き・編集(テキスト、Excel、PDF、DOCXなど)
  • フォルダの一覧表示、プロセスの一覧・終了

注意点

  • 先ほどの私のサンドボックスと違い、実際のPCのファイルやプロセスに作用します。削除や上書きなど影響の大きい操作は、実行前に内容をお伝えします。
  • sudo、format、shutdownなどの危険なコマンドはブロックされています。

何を実行したいか教えてください。たとえば「このフォルダのファイル一覧を出して」「このスクリプトを実行して」といった依頼ができます。

作業フォルダは、C:\Users\ohisa\claudeを使って

了解です。フォルダの有無を確認し、なければ作成します。

C:\Users\ohisa\claude はすでに存在していて、中身は空でした。今後のファイル作成やコマンド実行は、このフォルダを使います。

なお、各コマンドは別々のプロセスで動くため、Set-Location の効果は次のコマンドには引き継がれません。そのため、実行のたびにこのフォルダへ移動するか、絶対パスで指定します。

次は何をしますか。たとえば hello.cs を作って csc でコンパイル・実行する、といった動作確認もできます。

hello.csを作ってcscでコンパイル・実行して

hello.cs を作り、csc でコンパイルして実行できました。

出力はこうなりました。

Hello, World!
こんにちは、世界!

C:\Users\ohisa\claude には次の2つができています。

  • hello.cs: ソースコード
  • hello.exe: コンパイル済みの実行ファイル

使ったコンパイラは、64ビット版の .NET Framework 4(Framework64\v4.0.30319\csc.exe)です。日本語もそのまま表示されました。

別のプログラムを作ることもできます。たとえば、引数を受け取るものやファイルを読み書きするものなどです。

写真

image.png

hello.cs

using System;

class Hello
{
    static void Main()
    {
        Console.WriteLine("Hello, World!");
        Console.WriteLine("こんにちは、世界!");
    }
}

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?