Creating MCP Tools
Overview
Section titled “Overview”MCP tools in Greentic run on a shared MCP rail and are reached over one of two transports (see MCP Overview):
- local-wasm — a
wasix:mcp/routerWASM component, scaffolded withgtdx new --kind mcp, that the runner executes in-process. Best for sandboxed, signed tools with no network hop. - http — a remote MCP server reached over Streamable HTTP. Register an existing or hosted server directly.
This page also covers generating a WASM component from an API description (OpenAPI or Google Discovery) when you want to turn an existing API surface into callable tools.
Use these paths when you want a digital worker to call systems such as weather APIs, GitHub, Google APIs, ticketing systems, CRMs, HR systems, inventory systems, or internal HTTP services.
Create a Local-WASM Tool
Section titled “Create a Local-WASM Tool”A local-wasm tool is a wasix:mcp/router WASM component packaged as a .gtxpack and executed in-process by the runner.
-
Scaffold the router component
Terminal window gtdx new --kind mcp my-toolThis generates a
wasix:mcp/routercomponent that exportswasix:mcp/router@25.6.18. -
Publish the
.gtxpackto the storeThe store validates
kind: wasix:mcp/routeragainst itsdescribe-mcp-v1schema. -
Register the server in greentic-admin
Admin pulls the
.gtxpack, verifies itssha256and Ed25519 signature against trusted publisher keys, and caches the tool list by runninglist_toolsat registration (best-effort, non-fatal —toolsis left null if the probe fails). -
Use it
The Designer flow-editor prompt and the agentic-worker tool picker surface the cached tools with no HTTP probe. At runtime the runner pulls, verifies, caches, and executes the component in-process.
gtdx new --kind accepts design, bundle, deploy, provider, wasm-component, mcp, and llm. See gtdx CLI for the full scaffolding surface.
Generate a Publish-Ready MCP Extension
Section titled “Generate a Publish-Ready MCP Extension”gtdx new --kind mcp --from-openapi is the high-level wrapper around greentic-mcp-gen.
It generates a wasix:mcp/router component from an OpenAPI or Swagger spec and
auto-authors describe.json — populating runtime.permissions.network from the spec’s
servers and secret_requirements from its security schemes — producing a publish-ready
extension in one step.
-
Install dependencies
Install the
greentic-mcp-genbinary (requires aGITHUB_TOKENwith access to the private repo) and thewasm32-wasip2Rust target:Terminal window export GITHUB_TOKEN=ghp_...cargo binstall greentic-mcp-generatorrustup target add wasm32-wasip2cargo,cargo-component, andgtdxmust also be available (gtc installinstallsgtdx). -
Generate from an OpenAPI spec
Terminal window gtdx new --kind mcp --from-openapi ./openapi/weatherapi.yamlgtdxshells out togreentic-mcp-gen, which produces thewasix:mcp/routercomponent. It then auto-authorsdescribe.jsonwith:runtime.permissions.network— derived from the spec’sserverslist, so the component has exactly the network access the API requires.secret_requirements— derived from the spec’s security schemes (e.g. API key, OAuth 2.0 scopes), so credential injection is wired automatically.
-
What gets produced
my-tool/├── describe.json # auto-authored manifest (network + secrets pre-filled)├── Cargo.toml└── target/wasm32-wasip2/└── release/└── my_tool.component.wasmValidate before publishing:
Terminal window gtdx validate .gtdx lint --publish -
Publish to the store
Pass the pre-built WASM with
--wasmsogtdx publishskipscargo component buildand packages the generated artifact directly:Terminal window gtdx publish \--wasm ./target/wasm32-wasip2/release/my_tool.component.wasm \--manifest ./Cargo.toml \--registry store.greentic.cloud \--sign --key-id my-key \.The store validates
kind: wasix:mcp/routeragainst thedescribe-mcp-v1schema and verifies the Ed25519 signature.
A sibling passthrough greentic-dev mcp gen <args...> reaches the same generator
directly when you prefer the lower-level greentic-mcp-gen surface from within the
gtc dev toolchain.
Generate From OpenAPI
Section titled “Generate From OpenAPI”-
Prepare an OpenAPI or Swagger spec
Put the API description in your pack or workspace, for example:
openapi/weatherapi.yaml -
List generated tools
Terminal window greentic-mcp-gen \--spec ./openapi/weatherapi.yaml \--list-tools -
Inspect the input schema for an operation
Terminal window greentic-mcp-gen \--spec ./openapi/weatherapi.yaml \--tool-schema forecast_weather -
Inspect the HTTP execution plan
Terminal window greentic-mcp-gen \--spec ./openapi/weatherapi.yaml \--tool-plan forecast_weather -
Generate the component
Terminal window greentic-mcp-gen \--spec ./openapi/weatherapi.yaml \--output-dir ./output
The installed generator supports single-spec mode and batch mode. In batch mode it reads from ./input and writes generated WASM files to ./output unless you override those directories.
Generate From Google Discovery
Section titled “Generate From Google Discovery”For Google APIs, use discovery support directly:
greentic-mcp-gen discovery \ --url "https://sheets.googleapis.com/$discovery/rest?version=v4" \ --profile sheets-crm \ --out ./outputProfiles restrict large APIs to a useful operation subset. The generator includes profile commands:
greentic-mcp-gen profiles listgreentic-mcp-gen profiles show sheets-crmYou can also convert Discovery to OpenAPI first:
greentic-mcp-gen discovery-to-openapi \ --url "https://sheets.googleapis.com/$discovery/rest?version=v4" \ --profile sheets-crm \ --out ./specs/sheets.openapi.jsonThen run the normal OpenAPI generation path against ./specs/sheets.openapi.json.
Use the Tool in a Flow
Section titled “Use the Tool in a Flow”Once the generated component is available to the pack/runtime, call it with mcp.exec:
nodes: forecast_weather: mcp.exec: component: weather_api action: forecast_weather args: q: in.q_location days: 3 routing: - to: weather_textUse component for the logical component name, action for the operation, and args for the operation input.
Validate Tool Maps
Section titled “Validate Tool Maps”For tool-map based MCP wiring, keep a toolmap.json near the component artifacts:
{ "tools": [ { "name": "weather_api", "component": "./output/weatherapi_current.component.wasm", "entry": "tool_invoke", "timeout_ms": 5000, "max_retries": 1, "retry_backoff_ms": 250 } ]}Run doctor checks:
greentic-dev mcp doctor providers/weather --jsonThe doctor accepts a relative path to a tool-map file or a directory containing one of:
toolmap.jsontoolmap.yamltoolmap.ymlmcp.jsonmcp.yaml
It checks duplicate tool names, resolves component paths, and reports whether the referenced WASM files exist.
Package With a Pack
Section titled “Package With a Pack”An MCP tool is useful only when the pack also carries the right runtime information:
- generated
.wasmcomponent artifact - flow nodes that call the component with
mcp.exec - binding hints for required MCP servers or endpoints
- secret requirements for API keys and OAuth tokens
- network allowlists for outbound calls
- observability/control settings for audit, tracing, retries, and policy
Use the pack and bundle wizard flow for packaging. Coding agents should fetch the current wizard schema first, fill the answers JSON, then replay the wizard non-interactively:
gtc wizard --schemagtc wizard --answers pack-create-answers.jsonCustom Components
Section titled “Custom Components”If the integration is not well represented by OpenAPI or Discovery, create a custom Greentic component instead of forcing it into the MCP generator. Use the component wizard and current component templates:
gtc wizard --schemagreentic-component wizard --schemaThen use the generated answers file with the relevant wizard command. The exact answers schema is versioned by the installed CLI, so always inspect --schema before generating files by hand or with a coding agent.
Testing Guidance
Section titled “Testing Guidance”Before packaging a generated MCP component:
- Use
--list-toolsto confirm the expected operations exist. - Use
--tool-schemato confirm required arguments and JSON shapes. - Use
--tool-planto confirm the HTTP method, URL, path/query/body mapping, and base URL. - Run the component against representative inputs in your local test harness.
- Run
greentic-dev mcp doctorfor tool-map based wiring.
Best Practices
Section titled “Best Practices”- Prefer generated MCP components for API-backed tools.
- Keep operation names stable after flows depend on them.
- Put API keys and OAuth tokens in secrets, not generated source or flow files.
- Declare expected network endpoints so deployment and security tooling can enforce policy.
- Keep retries and timeouts explicit for external systems.
- Capture tool latency and failures through observer/telemetry extensions.