Skip to main content
Tools run in an isolated JavaScript context. Use the built-in SDK for network and database calls. You cannot install packages inside a tool.

Inputs and secrets

Return a string or a JSON-compatible value. TryMCP sends the result to the client as text.

HTTP

sdk.http() accepts method, url, headers, and body. The default method is GET. URLs must use HTTPS. Private network targets are blocked.
Replace the example URL with your API. Add API_KEY as a secret. HTTP errors do not throw by themselves. Check ok or status. Call json() only when the body is JSON.

Database

Use sdk.db() to open a connection. The examples use PostgreSQL (pg) and MySQL (mysql2). The database must be reachable from TryMCP. Private network targets are blocked.
Add the five DB_ secrets above and a required string input named userId. Use db.query() for inserts, updates, and deletes. Keep SQL and table names in your code. Pass input values through bindings. PostgreSQL query results are returned as rows directly. Do not read a .rows property. Use RETURNING when a PostgreSQL write needs to return data.

Lodash

Use sdk.lodash to filter, group, and sort data. template() is disabled.
This example needs a required array parameter named items.

Logs

Console messages appear in Output during a run. Do not print secrets or return them to the client.