fastmcp 3.25.3 → 3.26.2
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/dist/FastMCP.cjs +1931 -0
- package/dist/FastMCP.cjs.map +1 -0
- package/dist/FastMCP.d.cts +754 -0
- package/dist/FastMCP.d.ts +3 -1
- package/dist/FastMCP.js +25 -4
- package/dist/FastMCP.js.map +1 -1
- package/dist/{OAuthProxy-BOCkkAhO.d.ts → OAuthProxy-jvsyum7s.d.cts} +5 -0
- package/dist/OAuthProxy-jvsyum7s.d.ts +524 -0
- package/dist/auth/index.cjs +1875 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +445 -0
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +34 -3
- package/dist/auth/index.js.map +1 -1
- package/dist/bin/fastmcp.cjs +152 -0
- package/dist/bin/fastmcp.cjs.map +1 -0
- package/dist/bin/fastmcp.d.cts +1 -0
- package/package.json +7 -4
package/dist/FastMCP.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { EventEmitter } from 'events';
|
|
|
9
9
|
import http from 'http';
|
|
10
10
|
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
-
import { O as OAuthProxy } from './OAuthProxy-
|
|
12
|
+
import { O as OAuthProxy } from './OAuthProxy-jvsyum7s.js';
|
|
13
13
|
|
|
14
14
|
declare class DiscoveryDocumentCache {
|
|
15
15
|
#private;
|
|
@@ -174,6 +174,7 @@ type Completion = {
|
|
|
174
174
|
type ArgumentValueCompleter<T extends FastMCPSessionAuth = FastMCPSessionAuth> = (value: string, auth?: T) => Promise<Completion>;
|
|
175
175
|
type InputPrompt<T extends FastMCPSessionAuth = FastMCPSessionAuth, Arguments extends InputPromptArgument<T>[] = InputPromptArgument<T>[], Args = PromptArgumentsToObject<Arguments>> = {
|
|
176
176
|
arguments?: InputPromptArgument<T>[];
|
|
177
|
+
complete?: (name: string, value: string, auth?: T) => Promise<Completion>;
|
|
177
178
|
description?: string;
|
|
178
179
|
load: (args: Args, auth?: T) => Promise<PromptResult>;
|
|
179
180
|
name: string;
|
|
@@ -187,6 +188,7 @@ type InputPromptArgument<T extends FastMCPSessionAuth = FastMCPSessionAuth> = Re
|
|
|
187
188
|
}>;
|
|
188
189
|
type InputResourceTemplate<T extends FastMCPSessionAuth, Arguments extends InputResourceTemplateArgument<T>[] = InputResourceTemplateArgument<T>[]> = {
|
|
189
190
|
arguments: Arguments;
|
|
191
|
+
complete?: (name: string, value: string, auth?: T) => Promise<Completion>;
|
|
190
192
|
description?: string;
|
|
191
193
|
load: (args: ResourceTemplateArgumentsToObject<Arguments>, auth?: T) => Promise<ResourceResult | ResourceResult[]>;
|
|
192
194
|
mimeType?: string;
|
package/dist/FastMCP.js
CHANGED
|
@@ -624,6 +624,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
624
624
|
if (completers[name]) {
|
|
625
625
|
return await completers[name](value, auth);
|
|
626
626
|
}
|
|
627
|
+
if (inputPrompt.complete) {
|
|
628
|
+
return await inputPrompt.complete(name, value, auth);
|
|
629
|
+
}
|
|
627
630
|
if (fuseInstances[name]) {
|
|
628
631
|
const result = fuseInstances[name].search(value);
|
|
629
632
|
return {
|
|
@@ -654,6 +657,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
654
657
|
if (completers[name]) {
|
|
655
658
|
return await completers[name](value, auth);
|
|
656
659
|
}
|
|
660
|
+
if (inputResourceTemplate.complete) {
|
|
661
|
+
return await inputResourceTemplate.complete(name, value, auth);
|
|
662
|
+
}
|
|
657
663
|
return {
|
|
658
664
|
values: []
|
|
659
665
|
};
|
|
@@ -1126,6 +1132,18 @@ function convertObjectToSnakeCase(obj) {
|
|
|
1126
1132
|
}
|
|
1127
1133
|
return result;
|
|
1128
1134
|
}
|
|
1135
|
+
function parseBasicAuthHeader(authHeader) {
|
|
1136
|
+
const basicMatch = authHeader?.match(/^Basic\s+(.+)$/);
|
|
1137
|
+
if (!basicMatch) return null;
|
|
1138
|
+
try {
|
|
1139
|
+
const credentials = Buffer.from(basicMatch[1], "base64").toString("utf-8");
|
|
1140
|
+
const credMatch = credentials.match(/^([^:]+):(.*)$/);
|
|
1141
|
+
if (!credMatch) return null;
|
|
1142
|
+
return { clientId: credMatch[1], clientSecret: credMatch[2] };
|
|
1143
|
+
} catch {
|
|
1144
|
+
return null;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1129
1147
|
var FastMCPEventEmitterBase = EventEmitter;
|
|
1130
1148
|
var FastMCPEventEmitter = class extends FastMCPEventEmitterBase {
|
|
1131
1149
|
};
|
|
@@ -1771,11 +1789,14 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1771
1789
|
try {
|
|
1772
1790
|
const params = new URLSearchParams(body);
|
|
1773
1791
|
const grantType = params.get("grant_type");
|
|
1792
|
+
const basicAuth = parseBasicAuthHeader(req.headers.authorization);
|
|
1793
|
+
const clientId = basicAuth?.clientId || params.get("client_id") || "";
|
|
1794
|
+
const clientSecret = basicAuth?.clientSecret ?? params.get("client_secret") ?? void 0;
|
|
1774
1795
|
let response;
|
|
1775
1796
|
if (grantType === "authorization_code") {
|
|
1776
1797
|
response = await oauthProxy.exchangeAuthorizationCode({
|
|
1777
|
-
client_id:
|
|
1778
|
-
client_secret:
|
|
1798
|
+
client_id: clientId,
|
|
1799
|
+
client_secret: clientSecret,
|
|
1779
1800
|
code: params.get("code") || "",
|
|
1780
1801
|
code_verifier: params.get("code_verifier") || void 0,
|
|
1781
1802
|
grant_type: "authorization_code",
|
|
@@ -1783,8 +1804,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1783
1804
|
});
|
|
1784
1805
|
} else if (grantType === "refresh_token") {
|
|
1785
1806
|
response = await oauthProxy.exchangeRefreshToken({
|
|
1786
|
-
client_id:
|
|
1787
|
-
client_secret:
|
|
1807
|
+
client_id: clientId,
|
|
1808
|
+
client_secret: clientSecret,
|
|
1788
1809
|
grant_type: "refresh_token",
|
|
1789
1810
|
refresh_token: params.get("refresh_token") || "",
|
|
1790
1811
|
scope: params.get("scope") || void 0
|