コンテンツにスキップ

MCP 概要

MCP (Model Context Protocol) は、AI model を external tool や data source に接続するための標準です。Greentic では次の用途で MCP を実装しています。

  • sandboxed な WASM environment での tool execution
  • 安全な external API access
  • database query
  • file system operation

WASM Sandboxing

MCP ツールは security のために分離された WebAssembly environment で実行されます。

Tool Discovery

自動的なツール登録と capability advertisement を提供します。

Type Safety

WIT interface により type-safe な tool invocation を実現します。

Observability

tool execution のための tracing と logging を標準で備えています。

LLM (with tool use)
▼ Tool Call Request
┌─────────────────────────────────┐
│ greentic-mcp │
│ (MCP Executor / WASI Bridge) │
└─────────────────────────────────┘
┌─────────────────────────────────┐
│ WASM Tool Component │
│ (Sandboxed execution) │
└─────────────────────────────────┘
▼ Tool Result
Back to LLM
tools/database-query.yaml
name: database_query
description: Query the customer database
parameters:
- name: query
type: string
description: SQL query to execute
required: true
- name: limit
type: integer
description: Maximum rows to return
default: 10
returns:
type: array
items:
type: object
- id: query_orders
type: mcp-tool
config:
tool: "database_query"
parameters:
query: "SELECT * FROM orders WHERE customer_id = '{{customer_id}}'"
limit: 5
output: orders_result
next: process_orders
- id: agent_step
type: llm
config:
model: "gpt-4"
system_prompt: "You are a helpful assistant with database access."
tools:
- database_query
- send_email
- create_ticket
tool_choice: "auto"
next: handle_response

Greentic には、いくつかの built-in MCP tool が用意されています。

ToolDescription
http_requestHTTP request を実行する
database_querydatabase を query する
file_readfile を読み取る(sandboxed)
file_writefile に書き込む(sandboxed)
send_emailemail を送信する
create_ticketsupport ticket を作成する

すべての MCP tool は WASM sandbox で実行されます。

  • 直接の filesystem access は不可
  • 明示的に許可されない限り network access は不可
  • memory isolation
  • CPU time limit

ツールは必要な capability を宣言します。

capabilities:
- network:outbound # Can make outbound requests
- filesystem:read # Can read files in sandbox