Cover image
Try Now
2024-12-09

OpenAPI规格=> MCP(模型上下文协议)工具

3 years

Works with Finder

1

Github Watches

3

Github Forks

12

Github Stars

OPENAPI Specifications => MCP (Model Context Protocol) Tools

  • 🔧 An utility library for converting OpenAPI specifications to MCP tools.
  • 🚀 Faster the development of MCP servers based on OPENAPI specifications.

Usage

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
  CallToolRequestSchema,
  ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { Converter } from 'openapi2mcptools';

const converter = new Converter({
  baseURL, // optional
  httpClient // optional
});
await converter.load({
  // specs
});
const tools = converter.getToolsList();
const toolCaller = converter.getToolsCaller();

const server = new Server(
  {
    name: 'mcp-server-openapi',
    version: '1.0.0',
  },
  {
    capabilities: {
      tools: {},
    },
  },
);

// Define available tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools,
  };
});

// Handle tool execution
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  return await toolCaller(request);
});

const transport = new StdioServerTransport();
await server.connect(transport);

Custom client

Set baseURL, headers, etc for http client.

export type RequestConfig = {
  url?: string;
  method?: string;
  headers?: any;
  params?: any;
  data?: any;
}

export interface HTTPClient {
  request: (requestConfig: RequestConfig) => Promise<{ data: any }>;
}

Example:

import axios from axios;
import { Converter } from 'openapi2mcptools';

const converter = new Converter({
  httpClient: axios
});

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Andris Teikmanis
  • Latvian GPT assistant for developing GPT applications

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Navid RezaeiSarchoghaei
  • Professional Flask/SQLAlchemy code guide. Follow: https://x.com/navid_re

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • https://cantaspinar.com
  • Summarizes videos and answers related questions.

  • Khalid kalib
  • Write professional emails

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://tovuti.be
  • Oede knorrepot die vasthoudt an de goeie ouwe tied van 't boerenleven

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • oatpp
  • Anthropic的模型上下文协议实现了燕麦++

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • zhaoyunxing92
  • MCP(消息连接器协议)服务

    Reviews

    4 (1)
    Avatar
    user_hvqHmsKD
    2025-04-16

    As a dedicated MCP application user, I highly recommend the MCP-Recon-Server by seyrup1987. This server has significantly improved my experience by providing reliable and high-performance resources for my projects. The installation was straightforward, and the user interface is intuitive. Excellent product overall!