Sponsored by Deepsite.site

MCP_TOOL_POISONING_ATTACKS

Created By
RyosukeDTomita8 months ago
Content

MCP_TOOL_POISONING_ATTACKS

un license

INDEX


ABOUT

MCP Client and MCP Server


ENVIRONMENT

  • node.js v22
  • mcp sdk
  • claude-3-5-haiku-20241022

NOTE

./servers/ipinfo/は現在npxを使ってMCP Clientから使用する形を取っている。 npxを使ってGitHubのリポジトリからinstallするにはpackage.jsonをリポジトリトップに配置する必要があるため,npx使用のための./package.jsonをリポジトリトップに配置している。


PREPARING

For Dev Container

  1. install VSCode, Docker
  2. install VSCode Extensions Dev ContainerS
  3. On the VSCode, Ctrl shift p and run Dev Containers: Rebuild Containers
  4. create .env and add ANTHROPIC_API_KEY
cat << EOF > mcp_client/.env
ANTHROPIC_API_KEY=your_anthropic_api_key
EOF
  1. create mcp_client/mcpservers.json

Docker

  1. create .env and add ANTHROPIC_API_KEY
cat << EOF > mcp_client/.env
ANTHROPIC_API_KEY=your_anthropic_api_key
EOF
  1. create mcp_client/mcpservers.json
  2. build docker image
docker compose build

HOW TO USE

Running in Dev Containers

cd mcp_client
yarn run bundle
node dist/index.js

Running to docker run

docker compose run -it mcp_client

EXAMPLE

example of mcp_client/mcpservers.json

{
  "mcpServers": {
    "github": {
      "command": "/usr/local/bin/npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_hogehoge",
        "PATH": "/usr/local/bin:/usr/bin:/bin"
      }
    },
    "git": {
      "command": "uv",
      "args": [
        "--directory",
        "/<path to mcp-servers>/mcp-servers/src/git",
        "run",
        "mcp-server-git"
      ]
    }
  }
}

NOTE

現状はmcpservers.jsonの中にある一番上のサーバを使用するようになっている。

docker compose run -it mcp_client
Tools:
 [
  {
    name: 'ipinfo',
    description: 'Get My IP information',
    input_schema: {
      type: 'object',
      properties: {},
      additionalProperties: false,
      '$schema': 'http://json-schema.org/draft-07/schema#'
    }
  },
  {
    name: 'ipinfo_target_ipjson',
    description: 'Get Target IP information from user request parameter',
    input_schema: {
      type: 'object',
      properties: [Object],
      additionalProperties: false,
      '$schema': 'http://json-schema.org/draft-07/schema#'
    }
  }
]
Enter your message: 8.8.8.8の情報を教えて
=====Request to Anthoropic API=====
 [ { role: 'user', content: '8.8.8.8の情報を教えて' } ]
=====Response from Anthropic API=====:
 {
  id: 'msg_012ZGLAfhWKmgDroHELiq6F6',
  type: 'message',
  role: 'assistant',
  model: 'claude-3-5-haiku-20241022',
  content: [
    {
      type: 'text',
      text: '8.8.8.8の情報を調べるために、ipinfo_target_ipjsonツールを使用します。'
    },
    {
      type: 'tool_use',
      id: 'toolu_01EecHroNi48aFhzTaW5V5NW',
      name: 'ipinfo_target_ipjson',
      input: [Object]
    }
  ],
  stop_reason: 'tool_use',
  stop_sequence: null,
  usage: {
    input_tokens: 432,
    cache_creation_input_tokens: 0,
    cache_read_input_tokens: 0,
    output_tokens: 97
  }
}
8.8.8.8の情報を調べるために、ipinfo_target_ipjsonツールを使用します。
=====MCP Server Tool result=====
: {
  content: [
    {
      type: 'text',
      text: '{"ip":"8.8.8.8","hostname":"dns.google","city":"Mountain View","region":"California","country":"US","loc":"38.0088,-122.1175","org":"AS15169 Google LLC","postal":"94043","timezone":"America/Los_Angeles","readme":"https://ipinfo.io/missingauth","anycast":true}'
    }
  ]
}
=====Response from Anthropic API after tool use=====
 この情報は、IPアドレス8.8.8.8の詳細を示しています。主な特徴は以下の通りです:

1. IP: 8.8.8.8
2. ホスト名: dns.google
3. 所在地:
   - 都市: Mountain View
   - 地域: カリフォルニア
   - 国: アメリカ合衆国(US)
4. 地理的座標: 北緯38.0088、西経-122.1175
5. 組織: AS15169 Google LLC
6. 郵便番号: 94043
7. タイムゾーン: アメリカ/ロサンゼルス
8. エニーキャスト: はい(true)

この8.8.8.8は、Googleが提供する公開DNSサーバーの1つで、一般的に多くのユーザーが利用している信頼性の高いDNSサービスです。

References

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor
WindsurfThe new purpose-built IDE to harness magic
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
DeepChatYour AI Partner on Desktop
Tavily Mcp
Amap Maps高德地图官方 MCP Server
Serper MCP ServerA Serper MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code