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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mcp-function-calling-adapter

v0.1.1

Published

This library provides a function calling adapter for the Model Context Protocol (MCP).

Readme

mcp-function-calling-adapter

English | 日本語

npm version License: MIT Check

This library provides a function calling adapter for the Model Context Protocol (MCP).

You can use standardized MCP Server implementations directly with function calling through this library.

Installation

pnpm add mcp-function-calling-adapter

Usage

Here's an example using it with the OpenAI API:

import { McpFunctionCallingAdapter } from "mcp-function-calling-adapter"

const adapter = new McpFunctionCallingAdapter("example", {
  "sequential-thinking": {
    command: "npx",
    args: ["-y", "@modelcontextprotocol/server-sequential-thinking"],
  },
})

const openai = new OpenAI({
  apiKey: "your api key here",
})

try {
  await adapter.startServers()

  const messages = [
    {
      role: "user",
      content: "What's the weather like in Paris today?",
    },
  ]
  const completion = await openai.chat.completions.create({
    model: "gpt-4o-mini",
    messages,
    tools: adapter.getTools().map((tool) => ({
      type: "function",
      function: {
        name: tool.name,
        description: tool.description ?? "",
        parameters: tool.inputSchema,
      },
    })),
    tool_choice: "auto",
  })

  // Call tool
  const toolCall = completion.choices.at(0)?.message.tool_calls?.at(0)
  if (toolCall && adapter.isRegisteredTool(toolCall.function.name)) {
    const response = await adapter.executeTool(
      toolCall.function.name,
      JSON.parse(toolCall.function.arguments)
    )
    messages.push(completion.choices[0].message)
    messages.push({
      role: "tool",
      tool_call_id: toolCall.id,
      content: response.content.toString(),
    })
  }
} finally {
  await adapter.clean()
}

API

startServers()

Starts the MCP servers and loads available tools.

clean()

Disconnects from the MCP servers.

getTools()

Returns a list of available tools. The response includes the tool name, description, and input JSONSchema, which can be directly used for function calling schema definitions.

isRegisteredTool(name: string)

Checks if a tool with the specified name is registered and available for use.

  • name: The name of the tool to check
  • Returns: boolean - true if the tool is registered, false otherwise

executeTool(name: string, args: Record<string, unknown>)

Executes a tool with the specified name and returns the response from the MCP Server.

  • name: The name of the tool to execute
  • args: Arguments to pass to the tool

Contributing

We welcome contributions! Please see our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.

Development

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Run tests: pnpm test
  4. Build: pnpm build

Changelog

See CHANGELOG.md for a list of changes and version history.

License

This project is licensed under the MIT License - see the LICENSE file for details.