@mediagraph/mcp 1.0.15 → 1.0.16
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/index.js +38 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1540,6 +1540,11 @@ var userTools = {
|
|
|
1540
1540
|
},
|
|
1541
1541
|
required: ["id"]
|
|
1542
1542
|
}
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
name: "reauthorize",
|
|
1546
|
+
description: "Re-run the OAuth authorization flow. Use this to switch to a different Mediagraph organization or re-authenticate.",
|
|
1547
|
+
inputSchema: { type: "object", properties: {}, required: [] }
|
|
1543
1548
|
}
|
|
1544
1549
|
],
|
|
1545
1550
|
handlers: {
|
|
@@ -1558,6 +1563,18 @@ var userTools = {
|
|
|
1558
1563
|
async update_membership(args, { client: client2 }) {
|
|
1559
1564
|
const { id, ...data } = args;
|
|
1560
1565
|
return successResult(await client2.updateMembership(id, data));
|
|
1566
|
+
},
|
|
1567
|
+
async reauthorize(_args, { reauthorize }) {
|
|
1568
|
+
if (!reauthorize) {
|
|
1569
|
+
return errorResult("Reauthorization is not available in this context.");
|
|
1570
|
+
}
|
|
1571
|
+
const result = await reauthorize();
|
|
1572
|
+
if (!result.success) {
|
|
1573
|
+
return errorResult("Re-authorization failed. Please complete the login in your browser and try again.");
|
|
1574
|
+
}
|
|
1575
|
+
return successResult(`Successfully re-authorized!
|
|
1576
|
+
Organization: ${result.organizationName || "Unknown"}
|
|
1577
|
+
User: ${result.userEmail || "Unknown"}`);
|
|
1561
1578
|
}
|
|
1562
1579
|
}
|
|
1563
1580
|
};
|
|
@@ -3745,7 +3762,22 @@ var client = new MediagraphClient({
|
|
|
3745
3762
|
apiUrl: config.apiUrl,
|
|
3746
3763
|
getAccessToken
|
|
3747
3764
|
});
|
|
3748
|
-
var toolContext = {
|
|
3765
|
+
var toolContext = {
|
|
3766
|
+
client,
|
|
3767
|
+
reauthorize: async () => {
|
|
3768
|
+
console.error("[MCP] Reauthorize requested, clearing tokens and starting new OAuth flow...");
|
|
3769
|
+
currentTokens = null;
|
|
3770
|
+
tokenStore.clear();
|
|
3771
|
+
const success = await runAutoAuth();
|
|
3772
|
+
if (!success) return { success: false };
|
|
3773
|
+
const stored = tokenStore.load();
|
|
3774
|
+
return {
|
|
3775
|
+
success: true,
|
|
3776
|
+
organizationName: stored?.organizationName,
|
|
3777
|
+
userEmail: stored?.userEmail
|
|
3778
|
+
};
|
|
3779
|
+
}
|
|
3780
|
+
};
|
|
3749
3781
|
var resourceContext = { client };
|
|
3750
3782
|
function getOrganizationSlug() {
|
|
3751
3783
|
const stored = tokenStore.load();
|
|
@@ -3770,6 +3802,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
3770
3802
|
});
|
|
3771
3803
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
3772
3804
|
const { name, arguments: args } = request.params;
|
|
3805
|
+
if (name === "reauthorize") {
|
|
3806
|
+
console.error(`[MCP] Tool call: ${name}`);
|
|
3807
|
+
const result2 = await handleTool(name, args || {}, toolContext);
|
|
3808
|
+
return { content: result2.content, isError: result2.isError };
|
|
3809
|
+
}
|
|
3773
3810
|
let token = await getAccessToken();
|
|
3774
3811
|
if (!token) {
|
|
3775
3812
|
if (isAuthInProgress) {
|