History

refresh mcp

Rhys Sullivan committed 7 months ago

Commit 3f52c601 parent 3fa21785 files · +121 −13Browse files

Showing the changes to plugins (3 of 5 files). Show all

Unified · Split

3 files
  1. plugins/mcp/http/index.ts +22 −0
  2. plugins/mcp/react/components.tsx +32 −0
  3. plugins/mcp/sdk/index.ts +12 −0
plugins/mcp/http/index.ts+22−0
@@ -55,6 +55,9 @@ type McpExecutorExtension = { · 54 unmodified lines
5555 updateSource: (
5656 input: McpUpdateSourceInput,
5757 ) => Effect.Effect<Source, Error>;
58+ refreshSource: (
59+ sourceId: Source["id"],
60+ ) => Effect.Effect<Source, Error>;
5861 removeSource: (
5962 sourceId: Source["id"],
6063 ) => Effect.Effect<boolean, Error>;
@@ -117,6 +120,14 @@ export const McpHttpGroup = HttpApiGroup.make("mcp") · 56 unmodified lines
117120 .addError(ControlPlaneNotFoundError)
118121 .addError(ControlPlaneStorageError),
119122 )
123+ .add(
124+ HttpApiEndpoint.post("refreshSource")`/workspaces/${workspaceIdParam}/plugins/mcp/sources/${sourceIdParam}/refresh`
125+ .addSuccess(SourceSchema)
126+ .addError(ControlPlaneBadRequestError)
127+ .addError(ControlPlaneForbiddenError)
128+ .addError(ControlPlaneNotFoundError)
129+ .addError(ControlPlaneStorageError),
130+ )
120131 .add(
121132 HttpApiEndpoint.del("removeSource")`/workspaces/${workspaceIdParam}/plugins/mcp/sources/${sourceIdParam}`
122133 .addSuccess(Schema.Struct({ removed: Schema.Boolean }))
@@ -284,6 +295,17 @@ export const mcpHttpPlugin = (): ExecutorHttpPlugin< · 161 unmodified lines
284295 ),
285296 )
286297 )
298+ .handle("refreshSource", ({ path }) =>
299+ resolveRequestedLocalWorkspace(
300+ "mcp.refreshSource",
301+ path.workspaceId,
302+ ).pipe(
303+ Effect.flatMap(() => executor.mcp.refreshSource(path.sourceId)),
304+ Effect.mapError((cause) =>
305+ mapPluginStorageError("mcp.refreshSource", cause)
306+ ),
307+ )
308+ )
287309 .handle("removeSource", ({ path }) =>
288310 resolveRequestedLocalWorkspace(
289311 "mcp.removeSource",
plugins/mcp/react/components.tsx+32−0
@@ -733,6 +733,25 @@ export function McpDetailPage(props: { · 732 unmodified lines
733733 client.mutation("mcp", "removeSource"),
734734 { mode: "promise" },
735735 );
736+ const refreshSource = useAtomSet(
737+ client.mutation("mcp", "refreshSource"),
738+ { mode: "promise" },
739+ );
740+ const refreshMutation = useExecutorMutation<Source["id"], Source>(async (sourceId) =>
741+ refreshSource({
742+ path: {
743+ workspaceId: props.source.scopeId,
744+ sourceId,
745+ },
746+ reactivityKeys: {
747+ sources: [props.source.scopeId],
748+ source: [props.source.scopeId, sourceId],
749+ sourceInspection: [props.source.scopeId, sourceId],
750+ sourceInspectionTool: [props.source.scopeId, sourceId],
751+ sourceDiscovery: [props.source.scopeId, sourceId],
752+ },
753+ })
754+ );
736755 const [confirmDelete, setConfirmDelete] = useState(false);
737756 const [isDeleting, setIsDeleting] = useState(false);
738757 const configResult = useAtomValue(
@@ -815,6 +834,19 @@ export function McpDetailPage(props: { · 76 unmodified lines
815834 <>
816835 <Button
817836 variant="outline"
837+ size="sm"
838+ type="button"
839+ onClick={() => {
840+ void refreshMutation.mutateAsync(props.source.id);
841+ }}
842+ disabled={refreshMutation.status === "pending"}
843+ >
844+ {refreshMutation.status === "pending" ? "Refreshing..." : "Refresh"}
845+ </Button>
846+ <Button
847+ variant="outline"
848+ size="sm"
849+ type="button"
818850 onClick={() =>
819851 void navigation.edit(props.source.id)}
820852 >
plugins/mcp/sdk/index.ts+12−0
@@ -163,6 +163,9 @@ export type McpSdk = { · 162 unmodified lines
163163 updateSource: (
164164 input: McpUpdateSourceInput,
165165 ) => Effect.Effect<Source, Error>;
166+ refreshSource: (
167+ sourceId: Source["id"],
168+ ) => Effect.Effect<Source, Error>;
166169 removeSource: (
167170 sourceId: Source["id"],
168171 ) => Effect.Effect<boolean, Error>;
@@ -948,6 +951,13 @@ export const mcpSdkPlugin = ( · 779 unmodified lines
948951 outputSchema: SourceSchema,
949952 execute: ({ args, source }) => source.updateSource(args),
950953 },
954+ {
955+ name: "refreshSource",
956+ description: "Refresh an MCP source and resync its catalog.",
957+ inputSchema: McpSourceIdInputSchema,
958+ outputSchema: SourceSchema,
959+ execute: ({ args, source }) => source.refreshSource(args.sourceId),
960+ },
951961 {
952962 name: "removeSource",
953963 description: "Remove an MCP source and its stored plugin data.",
@@ -1092,6 +1102,8 @@ export const mcpSdkPlugin = ( · 138 unmodified lines
10921102 provideRuntime(source.createSource(input)),
10931103 updateSource: (input) =>
10941104 provideRuntime(source.updateSource(input)),
1105+ refreshSource: (sourceId) =>
1106+ provideRuntime(source.refreshSource(sourceId)),
10951107 removeSource: (sourceId) =>
10961108 provideRuntime(source.removeSource(sourceId)),
10971109 startOAuth: (input) =>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t