豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 811e9c1

Browse files
fix: OIDC npm publish and graceful method-not-found handling
1 parent 24007b3 commit 811e9c1

File tree

6 files changed

+101
-19
lines changed

6 files changed

+101
-19
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ jobs:
2424
uses: actions/setup-node@v4
2525
with:
2626
node-version: '22'
27-
registry-url: 'https://registry.npmjs.org'
27+
28+
- name: Configure npm registry
29+
run: |
30+
npm config set registry https://registry.npmjs.org/
31+
npm config set //registry.npmjs.org/:_authToken ""
2832
2933
- name: Validate version matches tag
3034
run: |

dist/cli/index.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56355,6 +56355,13 @@ const log = {
5635556355

5635656356

5635756357

56358+
/**
56359+
* Check if an error is "Method not found" (-32601)
56360+
*/
56361+
function isMethodNotFound(error) {
56362+
const errorStr = String(error);
56363+
return errorStr.includes("-32601") || errorStr.includes("Method not found");
56364+
}
5635856365
/**
5635956366
* Probes an MCP server and returns capability snapshots
5636056367
*/
@@ -56427,7 +56434,12 @@ async function probeServer(options) {
5642756434
log.info(` Listed ${result.tools.tools.length} tools`);
5642856435
}
5642956436
catch (error) {
56430-
log.warning(` Failed to list tools: ${error}`);
56437+
if (isMethodNotFound(error)) {
56438+
log.info(" Server does not implement tools/list");
56439+
}
56440+
else {
56441+
log.warning(` Failed to list tools: ${error}`);
56442+
}
5643156443
}
5643256444
}
5643356445
else {
@@ -56441,7 +56453,12 @@ async function probeServer(options) {
5644156453
log.info(` Listed ${result.prompts.prompts.length} prompts`);
5644256454
}
5644356455
catch (error) {
56444-
log.warning(` Failed to list prompts: ${error}`);
56456+
if (isMethodNotFound(error)) {
56457+
log.info(" Server does not implement prompts/list");
56458+
}
56459+
else {
56460+
log.warning(` Failed to list prompts: ${error}`);
56461+
}
5644556462
}
5644656463
}
5644756464
else {
@@ -56455,16 +56472,26 @@ async function probeServer(options) {
5645556472
log.info(` Listed ${result.resources.resources.length} resources`);
5645656473
}
5645756474
catch (error) {
56458-
log.warning(` Failed to list resources: ${error}`);
56475+
if (isMethodNotFound(error)) {
56476+
log.info(" Server does not implement resources/list");
56477+
}
56478+
else {
56479+
log.warning(` Failed to list resources: ${error}`);
56480+
}
5645956481
}
56460-
// Also get resource templates
56482+
// Also try resource templates - some servers support resources but not templates
5646156483
try {
5646256484
const templatesResult = await client.listResourceTemplates();
5646356485
result.resourceTemplates = templatesResult;
5646456486
log.info(` Listed ${result.resourceTemplates.resourceTemplates.length} resource templates`);
5646556487
}
5646656488
catch (error) {
56467-
log.warning(` Failed to list resource templates: ${error}`);
56489+
if (isMethodNotFound(error)) {
56490+
log.info(" Server does not implement resources/templates/list");
56491+
}
56492+
else {
56493+
log.warning(` Failed to list resource templates: ${error}`);
56494+
}
5646856495
}
5646956496
}
5647056497
else {

dist/index.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56605,6 +56605,13 @@ const log = {
5660556605

5660656606

5660756607

56608+
/**
56609+
* Check if an error is "Method not found" (-32601)
56610+
*/
56611+
function isMethodNotFound(error) {
56612+
const errorStr = String(error);
56613+
return errorStr.includes("-32601") || errorStr.includes("Method not found");
56614+
}
5660856615
/**
5660956616
* Probes an MCP server and returns capability snapshots
5661056617
*/
@@ -56677,7 +56684,12 @@ async function probeServer(options) {
5667756684
log.info(` Listed ${result.tools.tools.length} tools`);
5667856685
}
5667956686
catch (error) {
56680-
log.warning(` Failed to list tools: ${error}`);
56687+
if (isMethodNotFound(error)) {
56688+
log.info(" Server does not implement tools/list");
56689+
}
56690+
else {
56691+
log.warning(` Failed to list tools: ${error}`);
56692+
}
5668156693
}
5668256694
}
5668356695
else {
@@ -56691,7 +56703,12 @@ async function probeServer(options) {
5669156703
log.info(` Listed ${result.prompts.prompts.length} prompts`);
5669256704
}
5669356705
catch (error) {
56694-
log.warning(` Failed to list prompts: ${error}`);
56706+
if (isMethodNotFound(error)) {
56707+
log.info(" Server does not implement prompts/list");
56708+
}
56709+
else {
56710+
log.warning(` Failed to list prompts: ${error}`);
56711+
}
5669556712
}
5669656713
}
5669756714
else {
@@ -56705,16 +56722,26 @@ async function probeServer(options) {
5670556722
log.info(` Listed ${result.resources.resources.length} resources`);
5670656723
}
5670756724
catch (error) {
56708-
log.warning(` Failed to list resources: ${error}`);
56725+
if (isMethodNotFound(error)) {
56726+
log.info(" Server does not implement resources/list");
56727+
}
56728+
else {
56729+
log.warning(` Failed to list resources: ${error}`);
56730+
}
5670956731
}
56710-
// Also get resource templates
56732+
// Also try resource templates - some servers support resources but not templates
5671156733
try {
5671256734
const templatesResult = await client.listResourceTemplates();
5671356735
result.resourceTemplates = templatesResult;
5671456736
log.info(` Listed ${result.resourceTemplates.resourceTemplates.length} resource templates`);
5671556737
}
5671656738
catch (error) {
56717-
log.warning(` Failed to list resource templates: ${error}`);
56739+
if (isMethodNotFound(error)) {
56740+
log.info(" Server does not implement resources/templates/list");
56741+
}
56742+
else {
56743+
log.warning(` Failed to list resource templates: ${error}`);
56744+
}
5671856745
}
5671956746
}
5672056747
else {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcp-server-diff",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"description": "Diff MCP server public interfaces - CLI tool and GitHub Action",
55
"main": "dist/index.js",
66
"bin": {

src/probe.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export interface ProbeOptions {
3030
customMessages?: CustomMessage[];
3131
}
3232

33+
/**
34+
* Check if an error is "Method not found" (-32601)
35+
*/
36+
function isMethodNotFound(error: unknown): boolean {
37+
const errorStr = String(error);
38+
return errorStr.includes("-32601") || errorStr.includes("Method not found");
39+
}
40+
3341
/**
3442
* Probes an MCP server and returns capability snapshots
3543
*/
@@ -114,7 +122,11 @@ export async function probeServer(options: ProbeOptions): Promise<ProbeResult> {
114122
result.tools = toolsResult as ToolsResult;
115123
log.info(` Listed ${result.tools.tools.length} tools`);
116124
} catch (error) {
117-
log.warning(` Failed to list tools: ${error}`);
125+
if (isMethodNotFound(error)) {
126+
log.info(" Server does not implement tools/list");
127+
} else {
128+
log.warning(` Failed to list tools: ${error}`);
129+
}
118130
}
119131
} else {
120132
log.info(" Server does not support tools");
@@ -127,7 +139,11 @@ export async function probeServer(options: ProbeOptions): Promise<ProbeResult> {
127139
result.prompts = promptsResult as PromptsResult;
128140
log.info(` Listed ${result.prompts.prompts.length} prompts`);
129141
} catch (error) {
130-
log.warning(` Failed to list prompts: ${error}`);
142+
if (isMethodNotFound(error)) {
143+
log.info(" Server does not implement prompts/list");
144+
} else {
145+
log.warning(` Failed to list prompts: ${error}`);
146+
}
131147
}
132148
} else {
133149
log.info(" Server does not support prompts");
@@ -140,18 +156,26 @@ export async function probeServer(options: ProbeOptions): Promise<ProbeResult> {
140156
result.resources = resourcesResult as ResourcesResult;
141157
log.info(` Listed ${result.resources.resources.length} resources`);
142158
} catch (error) {
143-
log.warning(` Failed to list resources: ${error}`);
159+
if (isMethodNotFound(error)) {
160+
log.info(" Server does not implement resources/list");
161+
} else {
162+
log.warning(` Failed to list resources: ${error}`);
163+
}
144164
}
145165

146-
// Also get resource templates
166+
// Also try resource templates - some servers support resources but not templates
147167
try {
148168
const templatesResult = await client.listResourceTemplates();
149169
result.resourceTemplates = templatesResult as ResourceTemplatesResult;
150170
log.info(
151171
` Listed ${result.resourceTemplates.resourceTemplates.length} resource templates`
152172
);
153173
} catch (error) {
154-
log.warning(` Failed to list resource templates: ${error}`);
174+
if (isMethodNotFound(error)) {
175+
log.info(" Server does not implement resources/templates/list");
176+
} else {
177+
log.warning(` Failed to list resource templates: ${error}`);
178+
}
155179
}
156180
} else {
157181
log.info(" Server does not support resources");

0 commit comments

Comments
 (0)