w
This commit is contained in:
+37
-5
@@ -17,15 +17,19 @@ export function registerAuthTools(server: McpServer): void {
|
||||
description: "Authenticate to Exchange EWS using NTLM credentials."
|
||||
+ " On first use all fields except domain are required."
|
||||
+ " On subsequent logins only password is needed — previously saved"
|
||||
+ " serverUrl, email, username, and domain are reused automatically from config."
|
||||
+ " Returns {success, message} on success or {success, error} on failure.",
|
||||
+ " serverUrl, email, username, and domain are reused automatically from config.",
|
||||
inputSchema: z.object({
|
||||
serverUrl: z.string().optional().describe("Server URL"),
|
||||
serverUrl: z.string().optional().describe("EWS server URL"),
|
||||
email: z.string().optional().describe("Email address"),
|
||||
username: z.string().optional().describe("NTLM username"),
|
||||
password: z.string().describe("NTLM password"),
|
||||
domain: z.string().optional().describe("NTLM domain"),
|
||||
}),
|
||||
outputSchema: z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string().optional(),
|
||||
error: z.string().optional(),
|
||||
}),
|
||||
},
|
||||
async ({ serverUrl, email, username, password, domain }) => {
|
||||
try {
|
||||
@@ -103,8 +107,14 @@ export function registerAuthTools(server: McpServer): void {
|
||||
"check_session",
|
||||
{
|
||||
description:
|
||||
"Check whether the current EWS session is authenticated. No parameters. Returns {authenticated, email, serverUrl} or {authenticated, error}.",
|
||||
"Check whether the current EWS session is authenticated. No parameters.",
|
||||
inputSchema: z.object({}),
|
||||
outputSchema: z.object({
|
||||
authenticated: z.boolean(),
|
||||
email: z.string().optional(),
|
||||
serverUrl: z.string().optional(),
|
||||
error: z.string().optional(),
|
||||
}),
|
||||
},
|
||||
async () => {
|
||||
try {
|
||||
@@ -117,6 +127,10 @@ export function registerAuthTools(server: McpServer): void {
|
||||
error: "Not logged in. Password not found in memory.",
|
||||
}),
|
||||
}],
|
||||
structuredContent: {
|
||||
authenticated: false,
|
||||
error: "Not logged in. Password not found in memory.",
|
||||
},
|
||||
};
|
||||
}
|
||||
const config = loadConfig();
|
||||
@@ -133,6 +147,12 @@ export function registerAuthTools(server: McpServer): void {
|
||||
error: result.error,
|
||||
}),
|
||||
}],
|
||||
structuredContent: {
|
||||
authenticated: result.ok,
|
||||
email: config.email,
|
||||
serverUrl: config.serverUrl,
|
||||
error: result.error,
|
||||
},
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
@@ -143,6 +163,10 @@ export function registerAuthTools(server: McpServer): void {
|
||||
error: error.message ?? String(error),
|
||||
}),
|
||||
}],
|
||||
structuredContent: {
|
||||
authenticated: false,
|
||||
error: error.message ?? String(error),
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
@@ -152,8 +176,12 @@ export function registerAuthTools(server: McpServer): void {
|
||||
"logout",
|
||||
{
|
||||
description:
|
||||
"Clear stored credentials (serverUrl, email, username, domain, password). No parameters. Returns {success, message}.",
|
||||
"Clear stored credentials (serverUrl, email, username, domain, password). No parameters.",
|
||||
inputSchema: z.object({}),
|
||||
outputSchema: z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string().optional(),
|
||||
}),
|
||||
},
|
||||
async () => {
|
||||
clearConfig();
|
||||
@@ -165,6 +193,10 @@ export function registerAuthTools(server: McpServer): void {
|
||||
message: "Logged out. Credentials cleared.",
|
||||
}),
|
||||
}],
|
||||
structuredContent: {
|
||||
success: true,
|
||||
message: "Logged out. Credentials cleared.",
|
||||
},
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user