npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spec2tools/core

v0.2.1

Published

Core utilities for OpenAPI parsing and authentication

Downloads

44

Readme

@spec2tools/core

Core utilities for OpenAPI parsing and authentication.

Installation

npm install @spec2tools/core

API

OpenAPI Parsing

import {
  loadOpenAPISpec,
  extractBaseUrl,
  extractAuthConfig,
  parseOperations,
  formatToolSchema,
  formatToolSignature,
} from '@spec2tools/core';

// Load an OpenAPI specification from file or URL
const spec = await loadOpenAPISpec('./openapi.yaml');

// Extract the base URL
const baseUrl = extractBaseUrl(spec);

// Extract authentication configuration
const authConfig = extractAuthConfig(spec);

// Parse operations into tool definitions
const tools = parseOperations(spec);

Authentication Manager

import { AuthManager } from '@spec2tools/core';

const authManager = new AuthManager(authConfig);

// Check if auth is required
if (authManager.requiresAuth()) {
  // Perform authentication (OAuth2, API Key, or Bearer token)
  await authManager.authenticate();
}

// Get auth headers for requests
const headers = authManager.getAuthHeaders();

Tool Execution

import { createExecutableTools, executeToolByName } from '@spec2tools/core';

// Create executable tools from tool definitions
const tools = createExecutableTools(toolDefs, baseUrl, authManager);

// Execute a tool by name
const result = await executeToolByName(tools, 'getUser', { id: '123' });

AI SDK Tools

import { toAISDKTools } from '@spec2tools/core';

// Convert core tools to AI SDK-compatible ToolSet
const aiTools = toAISDKTools(tools);

Code Mode

Collapse any AI SDK ToolSet into 2 tools (search + execute). The model discovers endpoints via keyword search and calls them by writing Python code, executed in a sandboxed Monty interpreter.

import { toCodeModeTools } from '@spec2tools/core';

// Convert N tools into 2 code-mode tools
const codeModeTools = toCodeModeTools(aiTools);

This also works with tools from any MCP server via the AI SDK:

import { createMCPClient } from 'ai';
import { toCodeModeTools } from '@spec2tools/core';

const client = await createMCPClient({
  transport: { type: 'sse', url: 'http://localhost:3000/sse' },
});

const tools = toCodeModeTools(await client.tools());

Error Classes

import {
  UnsupportedSchemaError,
  AuthenticationError,
  ToolExecutionError,
  SpecLoadError,
} from '@spec2tools/core';

Types

import type {
  HttpMethod,
  Tool,
  AuthType,
  AuthConfig,
  Session,
  OpenAPISpec,
  PathItem,
  Operation,
  Parameter,
  RequestBody,
  MediaType,
  Response,
  SchemaObject,
  SecurityScheme,
} from '@spec2tools/core';

Supported OpenAPI Features

Supported

  • GET, POST, PUT, PATCH, DELETE operations
  • Path parameters (string, number, boolean)
  • Query parameters (string, number, boolean)
  • Request body with simple JSON schemas (primitives, flat objects)
  • Security schemes: OAuth2 (authorization code with PKCE), API Key, Bearer token

Not Supported (throws error)

  • Nested objects beyond 1 level
  • Arrays of objects
  • anyOf, oneOf, allOf schemas
  • File uploads
  • $ref references

License

MIT