apipost-mcp-server-simple 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,7 +34,7 @@
34
34
  "command": "npx",
35
35
  "args": [
36
36
  "-y",
37
- "apipost-mcp-server-simple"
37
+ "apipost-mcp-server-simple@latest"
38
38
  ],
39
39
  "env": {
40
40
  "APIPOST_OPENAPI_URL": "您的 OpenAPI 分享链接",
@@ -27,7 +27,7 @@ export class ApipostClient {
27
27
  async loadDefinition() {
28
28
  if (this.openApiUrl) {
29
29
  try {
30
- console.error(`正在从 URL 获取 OpenAPI 定义: ${this.openApiUrl}...`);
30
+ // console.error(`正在从 URL 获取 OpenAPI 定义: ${this.openApiUrl}...`);
31
31
  const response = await axios.get(this.openApiUrl);
32
32
  // 显式断言类型
33
33
  this.spec = response.data;
@@ -38,7 +38,7 @@ export class ApipostClient {
38
38
  }
39
39
  else if (this.openApiFilePath) {
40
40
  try {
41
- console.error(`正在从文件读取 OpenAPI 定义: ${this.openApiFilePath}...`);
41
+ // console.error(`正在从文件读取 OpenAPI 定义: ${this.openApiFilePath}...`);
42
42
  const content = await fs.readFile(this.openApiFilePath, 'utf-8');
43
43
  this.spec = JSON.parse(content);
44
44
  }
@@ -103,7 +103,7 @@ export class ApipostClient {
103
103
  }
104
104
  const baseUrl = this.getBaseUrl();
105
105
  const url = `${baseUrl}${path}`;
106
- console.error(`正在执行 API: ${method} ${url}`);
106
+ // console.error(`正在执行 API: ${method} ${url}`);
107
107
  try {
108
108
  const response = await axios({
109
109
  method: method,
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
+ // 必须在任何 import 之前重定向 console.log,防止依赖库输出干扰 stdout
3
+ console.log = console.error;
2
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
5
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
6
  import { z } from 'zod';
5
7
  import { ApipostClient } from './apipost-client.js';
6
- // 禁用所有可能对 stdout 的自动日志输出
7
8
  import dotenv from 'dotenv';
8
9
  dotenv.config();
9
- // 再次确保没有任何库在通过 console.log 输出干扰信息
10
+ // 再次确保
10
11
  const originalLog = console.log;
11
- console.log = console.error; // 将所有 console.log 重定向到 stderr,防止破坏 MCP 通信
12
12
  const server = new McpServer({
13
13
  name: 'Apipost MCP Server Simple',
14
14
  version: '1.0.0',
@@ -84,14 +84,14 @@ async function main() {
84
84
  try {
85
85
  // 启动时预加载以验证配置
86
86
  await client.loadDefinition();
87
- console.error(`成功加载 OpenAPI 定义,包含 ${client.getApiList().length} 个 API。`);
87
+ // console.error(`成功加载 OpenAPI 定义,包含 ${client.getApiList().length} 个 API。`);
88
88
  }
89
89
  catch (e) {
90
90
  console.error(`警告: 启动时加载 OpenAPI 定义失败: ${e.message}`);
91
91
  }
92
92
  const transport = new StdioServerTransport();
93
93
  await server.connect(transport);
94
- console.error("Apipost MCP Server Simple 正在通过 stdio 运行");
94
+ // console.error("Apipost MCP Server Simple 正在通过 stdio 运行");
95
95
  }
96
96
  main().catch((error) => {
97
97
  console.error("main() 发生致命错误:", error);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "apipost-mcp-server-simple",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
- "build": "tsc",
6
+ "build": "rm -rf dist && tsc",
7
7
  "start": "node dist/index.js",
8
8
  "dev": "ts-node src/index.ts"
9
9
  },