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

@portel/mcp

v1.0.1

Published

MCP protocol utilities - client, transport, elicitation

Downloads

422

Readme

@portel/mcp

MCP (Model Context Protocol) client library for connecting to and interacting with MCP servers. Provides transport abstraction, configuration management, and user elicitation utilities.

Part of the Portel Ecosystem

┌─────────────────────────────────────────────────────────────────┐
│                        @portel/cli                              │
│            CLI utilities: formatting, progress, logging         │
└─────────────────────────────────────────────────────────────────┘
                              ▲
                              │
┌─────────────────────────────────────────────────────────────────┐
│                  @portel/mcp (this package)                     │
│              MCP protocol: client, transport, config            │
└─────────────────────────────────────────────────────────────────┘
                              ▲
                              │
┌─────────────────────────────────────────────────────────────────┐
│                     @portel/photon-core                         │
│         Core library: schema extraction, generators, UI         │
└─────────────────────────────────────────────────────────────────┘
                              ▲
                              │
        ┌─────────────────────┼─────────────────────┐
        │                     │                     │
┌───────┴───────┐    ┌───────┴───────┐    ┌───────┴───────┐
│ @portel/photon│    │    lumina     │    │ @portel/ncp   │
│  CLI + BEAM   │    │  REST runtime │    │ MCP orchestr. │
└───────────────┘    └───────────────┘    └───────────────┘

Use this package if: You're building tools that need to connect to MCP servers, call MCP tools, or manage MCP server configurations.

Installation

npm install @portel/mcp

Features

MCP Client

Connect to MCP servers and call tools.

import { MCPClient, SDKMCPClientFactory } from '@portel/mcp';

// Create client factory
const factory = new SDKMCPClientFactory();

// Connect to an MCP server
const client = await factory.create({
  command: 'npx',
  args: ['-y', '@anthropic/weather-mcp'],
});

// List available tools
const tools = await client.listTools();
console.log(tools);

// Call a tool
const result = await client.callTool('get-weather', { city: 'London' });
console.log(result);

// Disconnect when done
await client.disconnect();

MCP Proxy

Create a proxy object that maps tool calls to method calls.

import { createMCPProxy, SDKMCPClientFactory } from '@portel/mcp';

const factory = new SDKMCPClientFactory();
const client = await factory.create(config);

// Create proxy - tool names become methods
const mcp = createMCPProxy(client);

// Call tools as methods
const weather = await mcp.getWeather({ city: 'Tokyo' });
const forecast = await mcp.getForecast({ days: 5 });

Configuration Management

Load and save MCP server configurations (Claude Desktop format).

import {
  loadPhotonMCPConfig,
  savePhotonMCPConfig,
  getMCPServerConfig,
  setMCPServerConfig,
  listMCPServers,
} from '@portel/mcp';

// Load config from ~/.photon/mcp-servers.json
const config = loadPhotonMCPConfig();

// List configured servers
const servers = listMCPServers();
// => ['weather', 'database', 'github']

// Get specific server config
const weatherConfig = getMCPServerConfig('weather');

// Add/update a server
setMCPServerConfig('my-server', {
  command: 'node',
  args: ['./my-server.js'],
  env: { API_KEY: '${MY_API_KEY}' },
});

// Save changes
savePhotonMCPConfig(config);

User Elicitation

Prompt users for input during tool execution.

import { prompt, confirm, elicit, setElicitHandler } from '@portel/mcp';

// Simple prompts
const name = await prompt('What is your name?');
const proceed = await confirm('Continue?');

// Rich elicitation with schema
const result = await elicit({
  message: 'Configure settings',
  schema: {
    type: 'object',
    properties: {
      theme: { type: 'string', enum: ['light', 'dark'] },
      fontSize: { type: 'number', minimum: 8, maximum: 24 },
    },
  },
});

// Custom handler (for different UIs)
setElicitHandler(async (options) => {
  // Custom UI implementation
  return { action: 'submit', data: formData };
});

API Reference

MCP Client

| Export | Description | |--------|-------------| | MCPClient | Core MCP client class | | MCPClientFactory | Factory interface for creating clients | | SDKMCPClientFactory | Factory using @modelcontextprotocol/sdk | | createMCPProxy(client) | Create proxy for tool-as-method calls | | MCPError | Base error class | | MCPNotConnectedError | Client not connected error | | MCPToolError | Tool execution error |

Configuration

| Export | Description | |--------|-------------| | loadPhotonMCPConfig() | Load config from ~/.photon | | savePhotonMCPConfig(config) | Save config to ~/.photon | | getMCPServerConfig(name) | Get server config by name | | setMCPServerConfig(name, config) | Add/update server config | | removeMCPServerConfig(name) | Remove server config | | listMCPServers() | List all configured servers | | isMCPConfigured(name) | Check if server is configured | | resolveEnvVars(config) | Resolve ${VAR} in config |

Elicitation

| Export | Description | |--------|-------------| | prompt(message) | Simple text prompt | | confirm(message) | Yes/no confirmation | | elicit(options) | Rich form elicitation | | setPromptHandler(handler) | Set custom prompt handler | | setElicitHandler(handler) | Set custom elicit handler | | elicitReadline | Readline-based handler | | elicitNativeDialog | Native dialog handler |

Types

interface MCPServerConfig {
  command: string;
  args?: string[];
  env?: Record<string, string>;
}

interface MCPToolInfo {
  name: string;
  description?: string;
  inputSchema?: object;
}

interface MCPToolResult {
  content: Array<{ type: string; text?: string }>;
  isError?: boolean;
}

interface ElicitOptions {
  message: string;
  schema?: object;
  requestedFields?: string[];
}

interface ElicitResult {
  action: 'submit' | 'cancel' | 'skip';
  data?: Record<string, any>;
}

License

MIT