smedc-mcp-launcher 0.5.0
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/LICENSE +9 -0
- package/README.md +18 -0
- package/dist/index.d.ts +172 -0
- package/dist/index.js +3499 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SMEDC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# SMEDC MCP Launcher
|
|
2
|
+
|
|
3
|
+
Official stdio MCP launcher for SMEDC. It reads only `SMEDC_BASE_URL`, which must
|
|
4
|
+
be a canonical HTTPS origin. Browser sign-in uses OAuth Authorization Code with PKCE; credentials
|
|
5
|
+
are never accepted through command arguments, environment variables, or MCP tool inputs.
|
|
6
|
+
|
|
7
|
+
Commands: `serve`, `self-check`, `logout`, and `--version`.
|
|
8
|
+
|
|
9
|
+
The `serve` command exposes the authenticated `smedc_get_current_user` tool so an
|
|
10
|
+
employee can confirm the current SMEDC display name, email, and role without exposing
|
|
11
|
+
credentials or accepting a selector for another account.
|
|
12
|
+
|
|
13
|
+
`self-check` writes one safe JSON object with `ok`, `launcherVersion`, `serviceOrigin`, `platform`,
|
|
14
|
+
`secureStore`, `server`, and `mcp` fields. `logout` always attempts local cleanup and writes
|
|
15
|
+
`remoteRevocationConfirmed` and `localCredentialRemoved` booleans. Neither command writes
|
|
16
|
+
credential contents.
|
|
17
|
+
|
|
18
|
+
This public package has no npm provenance because the source repository is private.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
interface LauncherRuntimeConfig {
|
|
6
|
+
serviceUrl: string;
|
|
7
|
+
transport: "stdio";
|
|
8
|
+
}
|
|
9
|
+
interface LauncherRuntimeConfigInput {
|
|
10
|
+
smedcBaseUrl: string;
|
|
11
|
+
}
|
|
12
|
+
type LauncherRuntimeEnv = Partial<Record<"SMEDC_BASE_URL", string | undefined>>;
|
|
13
|
+
declare function createLauncherRuntimeConfig(input: LauncherRuntimeConfigInput): LauncherRuntimeConfig;
|
|
14
|
+
declare function loadLauncherRuntimeConfig(env?: LauncherRuntimeEnv): LauncherRuntimeConfig;
|
|
15
|
+
|
|
16
|
+
declare const MCP_LAUNCHER_SERVER_NAME = "smedc-mcp-launcher";
|
|
17
|
+
declare const MCP_LAUNCHER_SERVER_VERSION = "0.5.0";
|
|
18
|
+
declare function createSmedcMcpLauncherServer(config: LauncherRuntimeConfig): McpServer;
|
|
19
|
+
declare function runMcpLauncherStdioServer(config: LauncherRuntimeConfig): Promise<void>;
|
|
20
|
+
|
|
21
|
+
interface SecureCredentialStore {
|
|
22
|
+
get(): Promise<string | null>;
|
|
23
|
+
set(credential: string): Promise<void>;
|
|
24
|
+
delete(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
interface AuthorizationRequest {
|
|
27
|
+
url: URL;
|
|
28
|
+
state: string;
|
|
29
|
+
verifier: string;
|
|
30
|
+
}
|
|
31
|
+
interface LoopbackCallbackServer {
|
|
32
|
+
redirectUri: URL;
|
|
33
|
+
waitForResult(): Promise<{
|
|
34
|
+
received: true;
|
|
35
|
+
}>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
declare function createAuthorizationRequest(input: {
|
|
39
|
+
authorizationEndpoint: URL;
|
|
40
|
+
redirectUri: URL;
|
|
41
|
+
state?: string;
|
|
42
|
+
verifier?: string;
|
|
43
|
+
}): Promise<AuthorizationRequest>;
|
|
44
|
+
declare function createLoopbackCallbackServer(input: {
|
|
45
|
+
state: string;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
}): Promise<LoopbackCallbackServer>;
|
|
48
|
+
declare function redactSecrets(value: unknown): unknown;
|
|
49
|
+
|
|
50
|
+
type LauncherErrorCode = "AUTHENTICATION_REQUIRED" | "AUTHENTICATION_PENDING" | "SERVICE_UNAVAILABLE" | "FORBIDDEN" | "LAUNCHER_UPGRADE_REQUIRED";
|
|
51
|
+
declare class LauncherTypedError extends Error {
|
|
52
|
+
readonly code: LauncherErrorCode;
|
|
53
|
+
constructor(code: LauncherErrorCode);
|
|
54
|
+
}
|
|
55
|
+
interface OAuthTokenClient {
|
|
56
|
+
refresh(refreshCredential: string): Promise<{
|
|
57
|
+
accessToken: string;
|
|
58
|
+
refreshToken: string;
|
|
59
|
+
expiresAt?: number;
|
|
60
|
+
}>;
|
|
61
|
+
revoke(refreshCredential: string): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
interface LauncherLock {
|
|
64
|
+
acquire(): Promise<() => Promise<void>>;
|
|
65
|
+
}
|
|
66
|
+
declare class LauncherSession {
|
|
67
|
+
#private;
|
|
68
|
+
private readonly dependencies;
|
|
69
|
+
constructor(dependencies: {
|
|
70
|
+
origin: string;
|
|
71
|
+
secureStore?: SecureCredentialStore;
|
|
72
|
+
tokenClient: OAuthTokenClient;
|
|
73
|
+
lock?: LauncherLock;
|
|
74
|
+
});
|
|
75
|
+
ensureAccessToken(): Promise<string>;
|
|
76
|
+
establish(accessToken: string, refreshCredential: string, expiresAt: number): Promise<void>;
|
|
77
|
+
logout(): Promise<{
|
|
78
|
+
remoteRevocationConfirmed: boolean;
|
|
79
|
+
localCredentialRemoved: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
status(): Promise<{
|
|
82
|
+
authenticated: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
invalidate(): Promise<void>;
|
|
85
|
+
secureStoreAvailable(): Promise<boolean>;
|
|
86
|
+
waitForLogin(promise: Promise<void>): void;
|
|
87
|
+
private readCredential;
|
|
88
|
+
private storeCredential;
|
|
89
|
+
private deleteCredential;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare const LAUNCHER_BOOTSTRAP_TOOL_NAMES: readonly ["smedc_login", "smedc_logout", "smedc_auth_status"];
|
|
93
|
+
type LauncherBootstrapToolName = (typeof LAUNCHER_BOOTSTRAP_TOOL_NAMES)[number];
|
|
94
|
+
type LauncherBusinessToolName = "smedc_get_current_user" | "smedc_list_skills" | "search_document_evidence" | "list_structured_datasets" | "query_structured_dataset" | "describe_structured_dataset_coverage" | "upload_structured_dataset" | "upload_evidence_document" | "upload_quarantine_certificate" | "query_quarantine_certificates" | "archive_quarantine_certificates" | "get_source_document_download_url" | "get_evidence_document_status" | "get_import_status" | "get_partition_import_status" | "download_structured_partitions";
|
|
95
|
+
type LauncherToolName = LauncherBootstrapToolName | LauncherBusinessToolName;
|
|
96
|
+
interface LauncherToolResult {
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
content: Array<{
|
|
99
|
+
type: "text";
|
|
100
|
+
text: string;
|
|
101
|
+
}>;
|
|
102
|
+
isError: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface LauncherAuthentication {
|
|
105
|
+
login(): Promise<LauncherLoginResult>;
|
|
106
|
+
logout(): Promise<{
|
|
107
|
+
remoteRevocationConfirmed: boolean;
|
|
108
|
+
localCredentialRemoved: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
status(): Promise<{
|
|
111
|
+
authenticated: boolean;
|
|
112
|
+
}>;
|
|
113
|
+
accessToken(): Promise<string>;
|
|
114
|
+
invalidate(): Promise<void>;
|
|
115
|
+
selfCheck(): Promise<LauncherSelfCheck>;
|
|
116
|
+
}
|
|
117
|
+
type LauncherLoginResult = {
|
|
118
|
+
authenticated: true;
|
|
119
|
+
} | {
|
|
120
|
+
authenticated: false;
|
|
121
|
+
flow: "device";
|
|
122
|
+
verificationUri: string;
|
|
123
|
+
verificationUriComplete: string | null;
|
|
124
|
+
userCode: string;
|
|
125
|
+
instanceName: string;
|
|
126
|
+
instanceHostname: string;
|
|
127
|
+
openedBrowser: boolean;
|
|
128
|
+
};
|
|
129
|
+
interface LauncherSelfCheck {
|
|
130
|
+
ok: boolean;
|
|
131
|
+
launcherVersion: string;
|
|
132
|
+
serviceOrigin: string;
|
|
133
|
+
platform: string;
|
|
134
|
+
secureStore: {
|
|
135
|
+
available: boolean;
|
|
136
|
+
durableCredentialPresent: boolean;
|
|
137
|
+
};
|
|
138
|
+
server: {
|
|
139
|
+
reachable: boolean;
|
|
140
|
+
metadataCompatible: boolean;
|
|
141
|
+
minimumLauncherVersion: string | null;
|
|
142
|
+
recommendedLauncherVersion: string | null;
|
|
143
|
+
recommendedUpdateAvailable: boolean;
|
|
144
|
+
};
|
|
145
|
+
mcp: {
|
|
146
|
+
handshake: "ok" | "not_authenticated" | "unavailable";
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
interface LauncherToolDependencies {
|
|
150
|
+
config: LauncherRuntimeConfig;
|
|
151
|
+
auth: LauncherAuthentication;
|
|
152
|
+
fetchImplementation: typeof fetch;
|
|
153
|
+
}
|
|
154
|
+
interface LauncherToolRegistrar {
|
|
155
|
+
registerTool(name: string, options: {
|
|
156
|
+
title: string;
|
|
157
|
+
description: string;
|
|
158
|
+
inputSchema: z.ZodRawShape;
|
|
159
|
+
}, handler: (input: unknown) => Promise<LauncherToolResult>): void;
|
|
160
|
+
}
|
|
161
|
+
declare function createLauncherToolDependencies(input: {
|
|
162
|
+
config: LauncherRuntimeConfig;
|
|
163
|
+
auth?: LauncherAuthentication;
|
|
164
|
+
fetchImplementation?: typeof fetch;
|
|
165
|
+
}): LauncherToolDependencies;
|
|
166
|
+
declare function registerLauncherTools(registrar: LauncherToolRegistrar, dependencies: LauncherToolDependencies): void;
|
|
167
|
+
declare function createLauncherToolHandler(toolName: string, dependencies: LauncherToolDependencies): (input: unknown) => Promise<LauncherToolResult>;
|
|
168
|
+
declare function createOfficialLauncherAuthentication(config: LauncherRuntimeConfig): LauncherAuthentication;
|
|
169
|
+
|
|
170
|
+
declare function runCommand(): Promise<void>;
|
|
171
|
+
|
|
172
|
+
export { LAUNCHER_BOOTSTRAP_TOOL_NAMES, type LauncherAuthentication, type LauncherBootstrapToolName, type LauncherBusinessToolName, type LauncherErrorCode, type LauncherRuntimeConfig, type LauncherRuntimeConfigInput, LauncherSession, type LauncherToolDependencies, type LauncherToolName, type LauncherToolRegistrar, type LauncherToolResult, LauncherTypedError, MCP_LAUNCHER_SERVER_NAME, MCP_LAUNCHER_SERVER_VERSION, createAuthorizationRequest, createLauncherRuntimeConfig, createLauncherToolDependencies, createLauncherToolHandler, createLoopbackCallbackServer, createOfficialLauncherAuthentication, createSmedcMcpLauncherServer, loadLauncherRuntimeConfig, redactSecrets, registerLauncherTools, runCommand, runMcpLauncherStdioServer };
|