Overview
Your tool code runs in an isolated V8 runtime with a 64 MB memory limit. There is no file system access, norequire(), no import, and no access to the Node.js standard library. Instead, MCPCore injects a curated set of globals:
sdk.http(): HTTP requests
Make outbound HTTP requests to any external API or service. Each HTTP request has a 10-second timeout and a 10 MB response size limit, with a maximum of 5 redirects.
Response methods
Example: GET with auth
Example: POST with JSON body
sdk.db(): Database queries
Connect to a relational database and run queries. sdk.db() is powered by Knex.js under the hood, a battle-tested SQL query builder for Node.js. If you’re familiar with Knex, the API will feel natural. MCPCore wraps it with a simplified interface for the most common operations.
Always store connection credentials as secrets and reference them as
env.*. Never hardcode passwords in tool code.db.select(table, where?)
Fetch rows from a table, optionally filtered by column values.
Writing data
Usedb.query() for inserts, updates and deletes. On PostgreSQL, add RETURNING * to get the affected rows back.
db.destroy()
Connections are closed automatically when the tool finishes. Call await db.destroy() to close one earlier.
db.query(sql, values?)
Run a parameterised SQL query. Use ? placeholders and pass values in the same order. The result is an array of rows.
sdk.lodash: Utility functions
A subset of Lodash is available for data manipulation.
sdk.sleep(): Wait before trying again
Pauses the tool for a number of milliseconds, for example before retrying a rate-limited request. One call waits at most 2,000 ms; longer values are cut to 2,000 ms.
params: Tool inputs
params is a plain object containing the values the AI passed when calling the tool. The keys are the parameter names you defined in the tool schema.
env: Secrets
env contains the encrypted secrets you stored in the server’s Secrets tab. Reference them by their key name:
env is read-only. Values are strings. See Secrets for how to create and manage them.
console: Structured logging
Log messages from your tool code. During a test run, the output appears in the Run panel’s Logs section. During live calls, it isn’t shown in the dashboard or in Traffic Logs: it goes to MCPCore’s server logs, where exact secret values of 6 characters or more are masked. Shorter or encoded values aren’t, so never log secret values. To see something in Traffic Logs, include it in the tool’s response.
During live calls, a tool run can write up to 100 lines of up to 2,000 characters each. For large payloads, log a summary rather than the full object.