end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

ollama for win + qwen2.5:14b + mcphost for go によるローカルllmでのmcp

claude desktop for win では動作することが実感できましたので、 ollama for win + qwen2.5:14b + mcphost for go によるローカルllmでのmcp

playwright、file-system、sqlite の 3つのmcpを試しましたが、 ローカルllmの性能差が影響しているのでしょうか、 claude desktop に比べると、動作は今ひとつ。

参考url

step1 - install ollama for win

https://ollama.com/download/windows にあるインストーラを実行するだけで、 以下のように認識されます。

CONDA> where ollama
C:\Users\end0t\AppData\Local\Programs\Ollama\ollama.exe
CONDA> ollama --version
ollama version is 0.6.6

CONDA> ollama --help
Large language model runner

Usage:
  ollama [flags]
  ollama [command]

Available Commands:
  serve       Start ollama
  create      Create a model from a Modelfile
  show        Show information for a model
  run         Run a model
  stop        Stop a running model
  pull        Pull a model from a registry
  push        Push a model to a registry
  list        List models
  ps          List running models
  cp          Copy a model
  rm          Remove a model
  help        Help about any command

Flags:
  -h, --help      help for ollama
  -v, --version   Show version information

step2 - download local llm weight & biases

CONDA> ollama pull qwen2.5:14b

phi3、phi4、 pakachan/elyza-llama3-8b、dsasai/llama3-elyza-jp-8b、 lucas2024/mistral-nemo-japanese-instruct-2408:q8_0、 schroneko/gemma-2-2b-jpn-it も試しましたが、 これらを mcphost で実行すると

Error: registry.ollama.ai/library/phi3:14b does not support tools

のエラーとなり利用できませんでした。

step3 - install golang and mcphost

mcphost が go で実装されている為、goをインストールした上で mcphost をインストール。

https://go.dev/dl/go1.24.2.windows-amd64.msi

CONDA> where go
C:\Program Files\Go\bin\go.exe

CONDA> go install github.com/mark3labs/mcphost@latest
go: downloading github.com/mark3labs/mcphost v0.7.1
go: downloading github.com/spf13/cobra v1.8.1
go: downloading github.com/mark3labs/mcp-go v0.20.0
go: downloading github.com/charmbracelet/glamour v0.8.0
go: downloading github.com/charmbracelet/huh v0.3.0
go: downloading github.com/charmbracelet/huh/spinner v0.0.0-20241127125741-aad810dfbce6
go: downloading github.com/charmbracelet/lipgloss v1.0.0
go: downloading golang.org/x/term v0.30.0
go: downloading github.com/charmbracelet/log v0.4.0
go: downloading github.com/google/generative-ai-go v0.19.0
go: downloading google.golang.org/api v0.228.0
go: downloading github.com/ollama/ollama v0.5.1
go: downloading golang.org/x/sys v0.31.0
go: downloading github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a
go: downloading github.com/go-logfmt/logfmt v0.6.0
go: downloading github.com/charmbracelet/bubbles v0.20.0
go: downloading github.com/charmbracelet/bubbletea v1.2.4
go: downloading github.com/catppuccin/go v0.2.0
go: downloading github.com/charmbracelet/x/ansi v0.4.5
go: downloading github.com/rivo/uniseg v0.4.7
go: downloading github.com/yosida95/uritemplate/v3 v3.0.2
go: downloading github.com/inconshreveable/mousetrap v1.1.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading cloud.google.com/go/ai v0.8.0
go: downloading github.com/googleapis/gax-go/v2 v2.14.1
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4
go: downloading google.golang.org/grpc v1.71.0
go: downloading google.golang.org/protobuf v1.36.6
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading cloud.google.com/go v0.115.0
go: downloading github.com/charmbracelet/x/term v0.2.1
go: downloading github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f
go: downloading github.com/mattn/go-localereader v0.0.1
go: downloading github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6
go: downloading github.com/muesli/cancelreader v0.2.2
go: downloading golang.org/x/sync v0.12.0
go: downloading github.com/atotto/clipboard v0.1.4
go: downloading github.com/mattn/go-runewidth v0.0.16
go: downloading github.com/yuin/goldmark v1.7.4
go: downloading github.com/yuin/goldmark-emoji v1.0.3
go: downloading golang.org/x/text v0.23.0
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/alecthomas/chroma/v2 v2.14.0
go: downloading github.com/microcosm-cc/bluemonday v1.0.27
go: downloading github.com/muesli/reflow v0.3.0
go: downloading cloud.google.com/go/longrunning v0.5.7
go: downloading google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422
go: downloading golang.org/x/net v0.37.0
go: downloading github.com/aymerick/douceur v0.2.0
go: downloading github.com/gorilla/css v1.0.1
go: downloading github.com/dlclark/regexp2 v1.11.0
go: downloading cloud.google.com/go/auth v0.15.0
go: downloading github.com/googleapis/enterprise-certificate-proxy v0.3.6
go: downloading cloud.google.com/go/compute/metadata v0.6.0
go: downloading cloud.google.com/go/auth/oauth2adapt v0.2.8
go: downloading go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0
go: downloading github.com/google/s2a-go v0.1.9
go: downloading go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0
go: downloading golang.org/x/time v0.11.0
go: downloading golang.org/x/oauth2 v0.28.0
go: downloading go.opentelemetry.io/otel v1.34.0
go: downloading go.opentelemetry.io/otel/metric v1.34.0
go: downloading go.opentelemetry.io/otel/trace v1.34.0
go: downloading github.com/felixge/httpsnoop v1.0.4
go: downloading golang.org/x/crypto v0.36.0
go: downloading go.opentelemetry.io/auto/sdk v1.1.0
go: downloading github.com/go-logr/logr v1.4.2
go: downloading github.com/go-logr/stdr v1.2.2

CONDA> >where mcphost
C:\Users\end0t\go\bin\mcphost.exe

CONDA> mcphost --help
MCPHost is a CLI tool that allows you to interact with various AI models
through a unified interface. It supports various tools through MCP servers
and provides streaming responses.

Available models can be specified using the --model flag:
- Anthropic Claude (default): anthropic:claude-3-5-sonnet-latest
- OpenAI: openai:gpt-4
- Ollama models: ollama:modelname
- Google: google:modelname

Example:
  mcphost -m ollama:qwen2.5:3b
  mcphost -m openai:gpt-4
  mcphost -m google:gemini-2.0-flash

Usage:
  mcphost [flags]

Flags:
   --anthropic-api-key string   Anthropic API key
   --anthropic-url string       base URL for Anthropic API (defaults to api.anthropic.com)
   --config string              config file (default is $HOME/.mcp.json)
   --debug                      enable debug logging
   --google-api-key string      Google (Gemini) API key
-h, --help                       help for mcphost
   --message-window int         number of messages to keep in context (default 10)
  -m, --model string               model to use (format: provider:model, e.g. anthropic:claude-3-5-sonnet-latest or ollama:qwen2.5:3b) (default "anthropic:claude-3-5-sonnet-latest")
      --openai-api-key string      OpenAI API key
      --openai-url string          base URL for OpenAI API (defaults to api.openai.com)
      --system-prompt string       system prompt json file

step4 - edit .mcp.json

mcphost でのdefault が ~/.mcp.json ですので、以下のように作成します。

尚、内容は、claude desktopと全く同じです。

{
    "mcpServers": {
        "playwright": {
            "command": "npx",
            "args": [
                "@playwright/mcp@latest"
            ]
        },
        "file-system": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-filesystem",
                "/Users/end0t/tmp"
            ]
        },
        "sqlite": {
            "command": "uvx",
            "args": ["mcp-server-sqlite", "--db-path", "C:/Users/end0t/tmp/test.db"]
        }
    }
}

step5 - お試し

CONDA> mcphost -m ollama:qwen2.5:14b --debug --config "c:\\Users\\end0t\\.mcp.json"

と実行すると、利用できますが、各mcpサーバは、sqliteが使えるかも? 程度、 file-systemとplaywrightは全く動作しませんでした。

設定が不足しているのでしょうか?