@lightsage/mcp 0.4.14 → 0.4.15
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 +2 -2
- package/api/mcp.js +21 -5
- package/bin/mcp-server.js +1241 -396
- package/bin/mcp-server.js.map +43 -39
- package/esm/funcs/evalRunsList.d.ts +1 -1
- package/esm/funcs/evalRunsList.js +1 -1
- package/esm/landing-page.js +1 -1
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/mcp-server/mcp-server.js +1 -1
- package/esm/mcp-server/server.js +1 -1
- package/esm/mcp-server/tools/evalRunsList.js +1 -1
- package/esm/mcp-server/tools/evalRunsList.js.map +1 -1
- package/esm/models/createevaltemplaterequest.d.ts +2 -1
- package/esm/models/createevaltemplaterequest.d.ts.map +1 -1
- package/esm/models/createevaltemplaterequest.js +2 -1
- package/esm/models/createevaltemplaterequest.js.map +1 -1
- package/esm/models/evaltemplate.d.ts +1 -0
- package/esm/models/evaltemplate.d.ts.map +1 -1
- package/esm/models/evaltemplate.js +1 -0
- package/esm/models/evaltemplate.js.map +1 -1
- package/esm/models/updateevaltemplaterequest.d.ts +1 -0
- package/esm/models/updateevaltemplaterequest.d.ts.map +1 -1
- package/esm/models/updateevaltemplaterequest.js +1 -0
- package/esm/models/updateevaltemplaterequest.js.map +1 -1
- package/esm/models/v2publictask.d.ts +24 -0
- package/esm/models/v2publictask.d.ts.map +1 -1
- package/esm/models/v2publictask.js +23 -0
- package/esm/models/v2publictask.js.map +1 -1
- package/esm/tool-names.js +1 -1
- package/esm/tool-names.js.map +1 -1
- package/lib/oauth.js +182 -9
- package/lib/profile.js +79 -0
- package/package.json +7 -4
- package/src/funcs/evalRunsList.ts +1 -1
- package/src/landing-page.ts +1 -1
- package/src/lib/config.ts +3 -3
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +1 -1
- package/src/mcp-server/tools/evalRunsList.ts +1 -1
- package/src/models/createevaltemplaterequest.ts +6 -2
- package/src/models/evaltemplate.ts +4 -0
- package/src/models/updateevaltemplaterequest.ts +2 -0
- package/src/models/v2publictask.ts +42 -0
- package/src/tool-names.ts +1 -1
- package/test/mcp-auth.test.js +203 -0
package/README.md
CHANGED
|
@@ -33,9 +33,9 @@ Lightsage Public API: Public API for Lightsage CLI and external integrations.
|
|
|
33
33
|
<details>
|
|
34
34
|
<summary>Claude Desktop</summary>
|
|
35
35
|
|
|
36
|
-
Install the MCP server as a Desktop Extension using the pre-built [`mcp-server.mcpb`](https://github.com/lightsagehq/mcp/releases/download/v0.4.
|
|
36
|
+
Install the MCP server as a Desktop Extension using the pre-built [`mcp-server.mcpb`](https://github.com/lightsagehq/mcp/releases/download/v0.4.15/mcp-server.mcpb) file:
|
|
37
37
|
|
|
38
|
-
Simply drag and drop the [`mcp-server.mcpb`](https://github.com/lightsagehq/mcp/releases/download/v0.4.
|
|
38
|
+
Simply drag and drop the [`mcp-server.mcpb`](https://github.com/lightsagehq/mcp/releases/download/v0.4.15/mcp-server.mcpb) file onto Claude Desktop to install the extension.
|
|
39
39
|
|
|
40
40
|
The MCP bundle package includes the MCP server and all necessary configuration. Once installed, the server will be available without additional setup.
|
|
41
41
|
|
package/api/mcp.js
CHANGED
|
@@ -6,8 +6,10 @@ import {
|
|
|
6
6
|
oauthEnabled,
|
|
7
7
|
verifyOAuthToken,
|
|
8
8
|
wwwAuthenticateHeader,
|
|
9
|
-
|
|
9
|
+
exchangeForLightsageIdentity,
|
|
10
|
+
exchangeFailureResponse,
|
|
10
11
|
} from "../lib/oauth.js";
|
|
12
|
+
import { registerProfileTool } from "../lib/profile.js";
|
|
11
13
|
|
|
12
14
|
const logLevel = process.env.MCP_LOG_LEVEL || "info";
|
|
13
15
|
const logger = createConsoleLogger(logLevel);
|
|
@@ -99,10 +101,11 @@ export default async function handler(req, res) {
|
|
|
99
101
|
// A caller-supplied Lightsage API key remains a first-class authentication
|
|
100
102
|
// path when OAuth is enabled. If no key is present, verify the Clerk OAuth
|
|
101
103
|
// access token and exchange that identity for a Lightsage public-API key.
|
|
104
|
+
let profile = null;
|
|
102
105
|
if (useOAuth && !requestApiKey) {
|
|
103
106
|
let auth;
|
|
104
107
|
try {
|
|
105
|
-
auth = await verifyOAuthToken(req);
|
|
108
|
+
auth = await verifyOAuthToken(req, logger);
|
|
106
109
|
} catch (error) {
|
|
107
110
|
logger.error("OAuth token verification error", {
|
|
108
111
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -117,13 +120,21 @@ export default async function handler(req, res) {
|
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
123
|
+
const identity = await exchangeForLightsageIdentity(
|
|
124
|
+
auth.userId,
|
|
125
|
+
auth.clientId,
|
|
126
|
+
);
|
|
127
|
+
headers.set("lightsage-api-key-auth", identity.apiKey);
|
|
128
|
+
profile = identity.profile;
|
|
122
129
|
} catch (error) {
|
|
123
130
|
logger.error("Lightsage key exchange failed", {
|
|
124
131
|
error: error instanceof Error ? error.message : String(error),
|
|
125
132
|
});
|
|
126
|
-
|
|
133
|
+
const failure = exchangeFailureResponse(req, error);
|
|
134
|
+
for (const [name, value] of Object.entries(failure.headers)) {
|
|
135
|
+
res.setHeader(name, value);
|
|
136
|
+
}
|
|
137
|
+
res.status(failure.status).json(failure.body);
|
|
127
138
|
return;
|
|
128
139
|
}
|
|
129
140
|
}
|
|
@@ -146,6 +157,11 @@ export default async function handler(req, res) {
|
|
|
146
157
|
getSDK: () => buildSDK(headers, flags, disableStaticAuth, logger),
|
|
147
158
|
});
|
|
148
159
|
|
|
160
|
+
// Only an OAuth connection has a profile; API-key callers skip the tool.
|
|
161
|
+
if (profile) {
|
|
162
|
+
registerProfileTool(mcpServer, profile);
|
|
163
|
+
}
|
|
164
|
+
|
|
149
165
|
mcpServer.server.onerror = (error) => {
|
|
150
166
|
logger.error("MCP protocol error", {
|
|
151
167
|
error: error instanceof Error ? error.message : String(error),
|