@context-pods/core
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@context-pods/core

Core utilities and types for the Context-Pods MCP (Model Context Protocol) development suite.

npm version License: MIT

Installation

npm install @context-pods/core

Features

  • Error Handling: Custom error classes for different failure scenarios
  • Logging: Simple, configurable logger with multiple log levels
  • Type Definitions: TypeScript types for pods, templates, and MCP components
  • Schema Validation: Zod schemas for validating configurations and manifests

Usage

Error Handling

import { ConfigurationError, TemplateError } from '@context-pods/core';

// Throw a configuration error
throw new ConfigurationError('Invalid pod name', { name: 'my pod' });

// Throw a template error
throw new TemplateError('Template not found', { template: 'unknown' });

Logging

import { Logger, LogLevel } from '@context-pods/core';

// Create a logger
const logger = new Logger({
  level: LogLevel.DEBUG,
  prefix: '[MyPod]',
});

// Log messages
logger.debug('Debug message');
logger.info('Info message');
logger.warn('Warning message');
logger.error('Error message');

// Create a child logger
const childLogger = logger.child('Component');
childLogger.info('From child logger');

Schema Validation

import { PodConfigSchema } from '@context-pods/core';

// Validate pod configuration
const config = {
  name: 'my-pod',
  description: 'My awesome pod',
  template: 'basic',
};

const result = PodConfigSchema.safeParse(config);
if (result.success) {
  console.log('Valid configuration:', result.data);
} else {
  console.error('Invalid configuration:', result.error);
}

API Reference

See the TypeScript definitions for detailed API documentation.

Key Exports

  • Error Classes: ConfigurationError, TemplateError, ValidationError
  • Logger: Configurable logging with multiple levels
  • Schemas: Zod schemas for validation (PodConfigSchema, TemplateManifestSchema, etc.)
  • Types: TypeScript types for all MCP components
  • Template Engine: Template processing and variable substitution
  • Template Selector: Intelligent template selection based on context

Related Packages

License

MIT

Package Sidebar

Install

npm i @context-pods/core

Weekly Downloads

121

Version

0.2.0

License

MIT

Unpacked Size

198 kB

Total Files

50

Last publish

Collaborators

  • cluddy