
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
@runapi.ai/mcp-core
Advanced tools
Reusable core for building RunAPI MCP servers: client, contract/pricing/schema queries, input-rule engine, and a createModelServer factory.
Reusable TypeScript primitives for building RunAPI Model Context Protocol servers.
@runapi.ai/mcp-core is the shared library used by the aggregate RunAPI MCP server and the per-model-line MCP servers. It provides the RunAPI HTTP client, contract helpers, pricing lookup, input validation, tool response helpers, and createModelServer for turning embedded RunAPI catalog data into MCP tools.
This package is a library. If you want a ready-to-run MCP server, use one of these packages instead:
@runapi.ai/mcp for the full RunAPI catalog.@runapi.ai/<model-line>-mcp for a focused model-line server.npm install @runapi.ai/mcp-core
Node.js 22 or newer is required.
| Export area | Purpose |
|---|---|
RunApiClient | Create tasks, fetch tasks, poll tasks, list models, search prompts, and check balance through the RunAPI API. |
createModelServer | Build an MCP server from embedded contract, pricing, and tool metadata. |
| Contract helpers | Resolve actions, models, fields, declared tool schemas, and action groups. |
| Pricing helpers | Look up embedded final pricing snapshots for a model/action pair. |
| Schema helpers | Convert RunAPI contract fields into Zod shapes and validate request params. |
| Input rules | Validate endpoint-level cross-field requirements before creating a task. |
| Response helpers | Format JSON MCP tool responses and friendly errors. |
import {
RunApiClient,
createModelServer,
type Contract,
type PricingConfig,
type ModelServerTool
} from "@runapi.ai/mcp-core";
const contract: Contract = {
catalog_models: ["example-model"],
actions: {
"example/text_to_image": {
model: "example",
endpoint: "text_to_image",
models: ["example-model"],
fields_by_model: {
"example-model": {
prompt: {
type: "string",
required: true,
description: "Image prompt."
}
}
}
}
}
};
const pricing: PricingConfig = {
endpoints: {}
};
const tools: ModelServerTool[] = [
{
name: "text_to_image",
description: "Create an example image task on RunAPI.",
service: "example",
action: "text_to_image",
models: ["example-model"]
}
];
const server = createModelServer({
name: "@runapi.ai/example-mcp",
version: "0.1.0",
lineSlug: "example",
contract,
pricing,
inputRules: {},
tools,
client: new RunApiClient()
});
Connect the returned server with an MCP transport, for example StdioServerTransport from @modelcontextprotocol/sdk.
Authenticated RunAPI calls resolve auth in this order:
RUNAPI_API_KEY, useful for headless and CI hosts.~/.config/runapi/config.json, created by the MCP login tool or runapi login.Headless hosts can set:
export RUNAPI_API_KEY=your_key_here
RunApiClient also accepts an injected config object and fetch implementation for tests or custom hosts.
@runapi.ai/mcp-core does not read catalog or pricing files at runtime. Server packages pass their embedded contract and pricing JSON into the library, which keeps published MCP packages deterministic and easy to smoke test.
The package is ESM-only and ships TypeScript declarations.
FAQs
Reusable core for building RunAPI MCP servers: client, contract/pricing/schema queries, input-rule engine, and a createModelServer factory.
The npm package @runapi.ai/mcp-core receives a total of 613 weekly downloads. As such, @runapi.ai/mcp-core popularity was classified as not popular.
We found that @runapi.ai/mcp-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.