mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-18 14:38:25 +01:00
Agents pane: CLI-only MCP, yaak mcp --http, and plugin deprecation (#761)
This commit is contained in:
1 parent
349e6f9197
commit
6132171791
32 files changed
+950
-524
No files matched your search
@@ -123,8 +123,6 @@ export default function Settings({ tab, hide }: Props) {
|
||||
<CountBadge count={settings.clientCertificates.length} />
|
||||
) : value === TAB_PLUGINS ? (
|
||||
<CountBadge count={plugins.filter((p) => p.source !== "bundled").length} />
|
||||
) : value === TAB_AGENTS && settings.mcpServerEnabled ? (
|
||||
<CountBadge count />
|
||||
) : value === TAB_PROXY && settings.proxy?.type === "enabled" ? (
|
||||
<CountBadge count />
|
||||
) : value === TAB_LICENSE && licenseCheck.check.data?.status === "personal_use" ? (
|
||||
|
||||
@@ -1,145 +1,72 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { settingsAtom } from "@yaakapp-internal/models";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { platform } from "@yaakapp-internal/platform";
|
||||
import { Heading, Icon, InlineCode, VStack } from "@yaakapp-internal/ui";
|
||||
import type { AppMetaData } from "@yaakapp-internal/rpc-schema";
|
||||
import { useAtomValue } from "jotai";
|
||||
import type { AgentSetupStatus, AppMetaData } from "@yaakapp-internal/rpc-schema";
|
||||
import { Banner, Heading, Icon, InlineCode, VStack } from "@yaakapp-internal/ui";
|
||||
import { useEffect } from "react";
|
||||
import { useKeyValue } from "../../hooks/useKeyValue";
|
||||
import { appInfo } from "../../lib/appInfo";
|
||||
import { usePluginInfos } from "../../hooks/usePluginInfo";
|
||||
import {
|
||||
AGENT_CLIENTS,
|
||||
type AgentClient,
|
||||
type AgentSetup,
|
||||
appSetup,
|
||||
cliSetup,
|
||||
skillInstallCommand,
|
||||
} from "../../lib/agentSetup";
|
||||
import { appInfo } from "../../lib/appInfo";
|
||||
import { rpc } from "../../lib/rpc";
|
||||
import { CopyIconButton } from "../CopyIconButton";
|
||||
import { Button } from "../core/Button";
|
||||
import { Editor } from "../core/Editor/LazyEditor";
|
||||
import { IconButton } from "../core/IconButton";
|
||||
import { Link } from "../core/Link";
|
||||
import { SegmentedControl } from "../core/SegmentedControl";
|
||||
import {
|
||||
ModelSettingRowBoolean,
|
||||
SettingRow,
|
||||
SettingValue,
|
||||
SettingCommand,
|
||||
SettingSnippet,
|
||||
SettingsList,
|
||||
SettingsSection,
|
||||
} from "../core/SettingRow";
|
||||
import { DeprecatedPluginBanner } from "./SettingsPlugins";
|
||||
|
||||
const MCP_URL = "http://127.0.0.1:64343/mcp";
|
||||
const CLI_INSTALL_COMMAND = "npm install -g @yaakapp/cli";
|
||||
const SKILL_INSTALL_COMMAND = "yaak agent install";
|
||||
const MCP_SERVER_PLUGIN = "@yaak/mcp-server";
|
||||
|
||||
export function SettingsAgents() {
|
||||
const settings = useAtomValue(settingsAtom);
|
||||
const { value: token } = useKeyValue<string | null>({
|
||||
namespace: "no_sync",
|
||||
key: "mcp_server_token",
|
||||
fallback: null,
|
||||
});
|
||||
const queryClient = useQueryClient();
|
||||
const { value: storedClient, set: setClient } = useKeyValue<AgentClient>({
|
||||
key: "agents_setup_client",
|
||||
fallback: "claude_code",
|
||||
});
|
||||
const client = AGENT_CLIENTS.find((c) => c.value === storedClient)?.value ?? "claude_code";
|
||||
const clientLabel = AGENT_CLIENTS.find((c) => c.value === client)?.label ?? "your agent";
|
||||
const cliVersion = useQuery({
|
||||
queryKey: ["cli_version"],
|
||||
queryFn: async () => (await rpc<AppMetaData>("cmd_metadata")).cliVersion,
|
||||
initialData: appInfo.cliVersion,
|
||||
});
|
||||
const setupStatus = useQuery({
|
||||
queryKey: ["agent_setup_status", client],
|
||||
queryFn: () => rpc<AgentSetupStatus>("cmd_agent_setup_status", { agent: client }),
|
||||
});
|
||||
const mcpServerPlugin = usePluginInfos().find(({ info }) => info.name === MCP_SERVER_PLUGIN);
|
||||
|
||||
useEffect(() => {
|
||||
return platform.window.onFocusChanged((focused) => {
|
||||
if (!focused) return;
|
||||
void queryClient.invalidateQueries({ queryKey: ["cli_version"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["agent_setup_status"] });
|
||||
});
|
||||
}, [queryClient]);
|
||||
|
||||
const cliInstalled = cliVersion.data != null;
|
||||
const cli = cliSetup(client);
|
||||
|
||||
return (
|
||||
<VStack space={1.5} className="mb-4">
|
||||
<div className="mb-3">
|
||||
<Heading>Agents</Heading>
|
||||
<p className="text-text-subtle">
|
||||
Connect AI coding agents like Claude Code and Cursor to Yaak, so they can read, edit, and
|
||||
send your requests.
|
||||
Connect AI coding agents like Claude Code and Cursor to Yaak.
|
||||
</p>
|
||||
</div>
|
||||
<SettingsList className="space-y-8">
|
||||
<SettingsSection
|
||||
title="Yaak CLI"
|
||||
description="Lets agents use Yaak from the command line, even with the app closed."
|
||||
>
|
||||
<SettingRow
|
||||
title="Status"
|
||||
description={
|
||||
cliVersion.data == null
|
||||
? "The Yaak CLI is not installed."
|
||||
: `Yaak CLI ${cliVersion.data} is installed.`
|
||||
}
|
||||
controlClassName="gap-2"
|
||||
>
|
||||
<IconButton
|
||||
size="sm"
|
||||
icon="refresh"
|
||||
title="Check again"
|
||||
spin={cliVersion.isFetching}
|
||||
onClick={() => cliVersion.refetch()}
|
||||
/>
|
||||
{cliVersion.data == null && (
|
||||
<Button
|
||||
variant="border"
|
||||
color="secondary"
|
||||
size="sm"
|
||||
onClick={() => platform.openUrl("https://yaak.app/docs/cli")}
|
||||
rightSlot={<Icon icon="external_link" />}
|
||||
>
|
||||
Install CLI
|
||||
</Button>
|
||||
)}
|
||||
</SettingRow>
|
||||
{cliVersion.data == null ? (
|
||||
<SettingRow title="Install" description="Install it with npm.">
|
||||
<SettingValue value={CLI_INSTALL_COMMAND} />
|
||||
</SettingRow>
|
||||
) : (
|
||||
<SettingRow
|
||||
title="Agent skill"
|
||||
description={
|
||||
<>
|
||||
Teach Claude Code, Cursor, Codex, and opencode to drive the{" "}
|
||||
<InlineCode>yaak</InlineCode> command, wherever they're installed.
|
||||
</>
|
||||
}
|
||||
>
|
||||
<SettingValue value={SKILL_INSTALL_COMMAND} />
|
||||
</SettingRow>
|
||||
)}
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection
|
||||
title="MCP server in the app"
|
||||
description="For agents that connect over HTTP, or to act on the workspaces open in Yaak."
|
||||
>
|
||||
<ModelSettingRowBoolean
|
||||
model={settings}
|
||||
modelKey="mcpServerEnabled"
|
||||
title="Enable MCP server"
|
||||
description={
|
||||
<>
|
||||
Serve Yaak's tools at <InlineCode>{MCP_URL}</InlineCode> while Yaak is open.
|
||||
</>
|
||||
}
|
||||
/>
|
||||
{settings.mcpServerEnabled && token != null && (
|
||||
<SettingRow
|
||||
title="Token"
|
||||
description="Agents send this as a bearer token."
|
||||
controlClassName="min-w-0 max-w-[min(24rem,40vw)] gap-2"
|
||||
>
|
||||
<SettingValue value={token} />
|
||||
</SettingRow>
|
||||
)}
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection
|
||||
title="Connect an agent"
|
||||
description="Pick your agent or editor to see how to add Yaak's MCP tools to it."
|
||||
>
|
||||
<div className="py-4 border-b border-border-subtle">
|
||||
<SettingsList>
|
||||
<SettingsSection title={null}>
|
||||
<div className="pb-4 border-b border-border-subtle">
|
||||
<SegmentedControl
|
||||
name="agents_setup_client"
|
||||
label="Agent"
|
||||
@@ -149,59 +76,65 @@ export function SettingsAgents() {
|
||||
options={AGENT_CLIENTS}
|
||||
/>
|
||||
</div>
|
||||
<SetupRow
|
||||
title="Through the Yaak CLI"
|
||||
description={
|
||||
cliVersion.data == null
|
||||
? "Recommended. Install the Yaak CLI above first."
|
||||
: `Recommended. ${cliSetup(client).where}`
|
||||
}
|
||||
setup={cliSetup(client)}
|
||||
/>
|
||||
{settings.mcpServerEnabled && token != null ? (
|
||||
<SetupRow
|
||||
title="Through the app"
|
||||
description={appSetup(client, MCP_URL, token).where}
|
||||
setup={appSetup(client, MCP_URL, token)}
|
||||
/>
|
||||
{cliInstalled ? (
|
||||
<div className="flex items-center gap-2 py-3 text-sm text-text-subtle border-b border-border-subtle">
|
||||
<Icon icon="check" size="sm" color="success" />
|
||||
<span>
|
||||
Yaak CLI <span className="text-text">{cliVersion.data}</span> is installed.
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
<SettingRow
|
||||
title="Through the app"
|
||||
description="Turn on the MCP server above to connect this way."
|
||||
>
|
||||
<span />
|
||||
</SettingRow>
|
||||
<div className="py-4 border-b border-border-subtle">
|
||||
<Banner color="info">
|
||||
<div className="flex items-center gap-2 text text-text">
|
||||
<Icon icon="square_terminal" color="info" />
|
||||
Install the Yaak CLI first
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-text-subtle">
|
||||
Agents launch it to reach Yaak, even with the app closed.
|
||||
</p>
|
||||
<SettingSnippet className="mt-3" language="shell" snippet={CLI_INSTALL_COMMAND} />
|
||||
<div className="mt-3 mb-1 flex items-center gap-4 text-sm">
|
||||
<Link href="https://yaak.app/docs/cli">Docs</Link>
|
||||
<span className="text-text-subtlest">
|
||||
Checks again when you come back to Yaak.
|
||||
</span>
|
||||
</div>
|
||||
</Banner>
|
||||
</div>
|
||||
)}
|
||||
{mcpServerPlugin != null && (
|
||||
<div className="py-4 border-b border-border-subtle">
|
||||
<DeprecatedPluginBanner
|
||||
plugin={mcpServerPlugin.plugin}
|
||||
name={mcpServerPlugin.info.displayName}
|
||||
>
|
||||
The two steps below replace it. Uninstall it once your agent is connected.
|
||||
</DeprecatedPluginBanner>
|
||||
</div>
|
||||
)}
|
||||
<SettingCommand
|
||||
title="Add the MCP server"
|
||||
description={cli.where}
|
||||
snippet={cli.snippet}
|
||||
language={cli.language}
|
||||
disabled={!cliInstalled}
|
||||
done={setupStatus.data?.mcpServer ? "Added" : null}
|
||||
/>
|
||||
<SettingCommand
|
||||
title="Install the skill"
|
||||
description={
|
||||
<>
|
||||
Lets {clientLabel} run the <InlineCode>yaak</InlineCode> command directly.
|
||||
</>
|
||||
}
|
||||
snippet={skillInstallCommand(client)}
|
||||
language="shell"
|
||||
disabled={!cliInstalled}
|
||||
done={setupStatus.data?.skill ? "Installed" : null}
|
||||
/>
|
||||
</SettingsSection>
|
||||
</SettingsList>
|
||||
</VStack>
|
||||
);
|
||||
}
|
||||
|
||||
function SetupRow({
|
||||
title,
|
||||
description,
|
||||
setup,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
setup: AgentSetup;
|
||||
}) {
|
||||
return (
|
||||
<div className="py-4 border-b border-border-subtle">
|
||||
<div className="text text-text">{title}</div>
|
||||
<div className="mt-1 text-sm text-text-subtle">{description}</div>
|
||||
<Editor
|
||||
readOnly
|
||||
hideGutter
|
||||
wrapLines
|
||||
heightMode="auto"
|
||||
stateKey={null}
|
||||
language={setup.language}
|
||||
defaultValue={setup.snippet}
|
||||
className="mt-3 border border-border-subtle rounded-md px-2"
|
||||
actions={<CopyIconButton size="sm" variant="border" text={setup.snippet} title="Copy setup" />}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2,13 +2,9 @@ import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import type { Plugin } from "@yaakapp-internal/models";
|
||||
import { patchModel, pluginsAtom } from "@yaakapp-internal/models";
|
||||
import type { PluginVersion } from "@yaakapp-internal/plugins";
|
||||
import { checkPluginUpdates, installPlugin, searchPlugins } from "@yaakapp-internal/plugins";
|
||||
import {
|
||||
checkPluginUpdates,
|
||||
installPlugin,
|
||||
searchPlugins,
|
||||
uninstallPlugin,
|
||||
} from "@yaakapp-internal/plugins";
|
||||
import {
|
||||
Banner,
|
||||
HStack,
|
||||
Icon,
|
||||
InlineCode,
|
||||
@@ -24,12 +20,11 @@ import {
|
||||
} from "@yaakapp-internal/ui";
|
||||
import classNames from "classnames";
|
||||
import { useAtomValue } from "jotai";
|
||||
import { useState } from "react";
|
||||
import { type ReactNode, useState } from "react";
|
||||
import { useInstallPlugin } from "../../hooks/useInstallPlugin";
|
||||
import { usePluginInfo } from "../../hooks/usePluginInfo";
|
||||
import { usePluginInfo, usePluginInfos } from "../../hooks/usePluginInfo";
|
||||
import { usePluginsKey, useRefreshPlugins } from "../../hooks/usePlugins";
|
||||
import { showConfirmDelete } from "../../lib/confirm";
|
||||
import { minPromiseMillis } from "../../lib/minPromiseMillis";
|
||||
import { usePromptUninstallPlugin } from "../../hooks/useUninstallPlugin";
|
||||
import { Button } from "../core/Button";
|
||||
import { Checkbox } from "../core/Checkbox";
|
||||
import { IconButton } from "../core/IconButton";
|
||||
@@ -205,7 +200,7 @@ function PluginTableRow({
|
||||
mutationKey: ["install_plugin", name],
|
||||
mutationFn: (name: string) => installPlugin(name, null),
|
||||
});
|
||||
const uninstall = usePromptUninstall(plugin?.id ?? null, displayName);
|
||||
const uninstall = usePromptUninstallPlugin(plugin?.id ?? null, displayName);
|
||||
const refreshPlugins = useRefreshPlugins();
|
||||
|
||||
return (
|
||||
@@ -296,7 +291,10 @@ function PluginSearch() {
|
||||
const debouncedQuery = useDebouncedValue(query);
|
||||
const results = useQuery({
|
||||
queryKey: ["plugins", debouncedQuery],
|
||||
queryFn: () => searchPlugins(query),
|
||||
queryFn: async () => {
|
||||
const { plugins } = await searchPlugins(query);
|
||||
return { plugins: plugins.filter((p) => p.deprecated == null) };
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -349,22 +347,77 @@ function InstalledPlugins({ plugins, className }: { plugins: Plugin[]; className
|
||||
</EmptyStateText>
|
||||
</div>
|
||||
) : (
|
||||
<Table scrollable className={className}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableHeaderCell className="w-0" />
|
||||
<TableHeaderCell>Display Name</TableHeaderCell>
|
||||
<TableHeaderCell>Name</TableHeaderCell>
|
||||
<TableHeaderCell>Version</TableHeaderCell>
|
||||
<TableHeaderCell />
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<tbody className="divide-y divide-surface-highlight">
|
||||
{plugins.map((p) => (
|
||||
<PluginTableRowForInstalledPlugin key={p.id} plugin={p} />
|
||||
))}
|
||||
</tbody>
|
||||
</Table>
|
||||
<div className={classNames(className, "h-full grid grid-rows-[auto_minmax(0,1fr)]")}>
|
||||
<DeprecatedPluginBanners />
|
||||
<Table scrollable>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableHeaderCell className="w-0" />
|
||||
<TableHeaderCell>Display Name</TableHeaderCell>
|
||||
<TableHeaderCell>Name</TableHeaderCell>
|
||||
<TableHeaderCell>Version</TableHeaderCell>
|
||||
<TableHeaderCell />
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<tbody className="divide-y divide-surface-highlight">
|
||||
{plugins.map((p) => (
|
||||
<PluginTableRowForInstalledPlugin key={p.id} plugin={p} />
|
||||
))}
|
||||
</tbody>
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DeprecatedPluginBanners() {
|
||||
const deprecated = usePluginInfos().filter(
|
||||
({ plugin, info }) => plugin.source !== "bundled" && info.deprecated != null,
|
||||
);
|
||||
return (
|
||||
<div className={classNames("flex flex-col gap-2", deprecated.length > 0 && "pb-3")}>
|
||||
{deprecated.map(({ plugin, info }) => (
|
||||
<DeprecatedPluginBanner key={plugin.id} plugin={plugin} name={info.displayName}>
|
||||
{withInlineCode(info.deprecated ?? "")}
|
||||
</DeprecatedPluginBanner>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Backtick spans in a package.json string, set as code. */
|
||||
function withInlineCode(text: string): ReactNode {
|
||||
return text
|
||||
.split("`")
|
||||
.map((part, i) => (i % 2 === 1 ? <InlineCode key={i}>{part}</InlineCode> : part));
|
||||
}
|
||||
|
||||
export function DeprecatedPluginBanner({
|
||||
children,
|
||||
name,
|
||||
plugin,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
name: string;
|
||||
plugin: Plugin;
|
||||
}) {
|
||||
const uninstall = usePromptUninstallPlugin(plugin.id, name);
|
||||
return (
|
||||
<Banner color="info" className="flex items-center gap-4">
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text text-text">The {name} plugin is deprecated.</div>
|
||||
<p className="mt-1 text-sm text-text-subtle">{children}</p>
|
||||
</div>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="border"
|
||||
title="Uninstall plugin"
|
||||
className="shrink-0"
|
||||
isLoading={uninstall?.isPending}
|
||||
onClick={() => uninstall?.mutate()}
|
||||
>
|
||||
Uninstall
|
||||
</Button>
|
||||
</Banner>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -393,31 +446,6 @@ function BundledPlugins({ plugins }: { plugins: Plugin[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
function usePromptUninstall(pluginId: string | null, name: string) {
|
||||
const mut = useMutation({
|
||||
mutationKey: ["uninstall_plugin", pluginId],
|
||||
mutationFn: async () => {
|
||||
if (pluginId == null) return;
|
||||
|
||||
const confirmed = await showConfirmDelete({
|
||||
id: `uninstall-plugin-${pluginId}`,
|
||||
title: "Uninstall Plugin",
|
||||
confirmText: "Uninstall",
|
||||
description: (
|
||||
<>
|
||||
Permanently uninstall <InlineCode>{name}</InlineCode>?
|
||||
</>
|
||||
),
|
||||
});
|
||||
if (confirmed) {
|
||||
await minPromiseMillis(uninstallPlugin(pluginId), 700);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return pluginId == null ? null : mut;
|
||||
}
|
||||
|
||||
function usePluginUpdates() {
|
||||
return useQuery({
|
||||
queryKey: ["plugin_updates", usePluginsKey()],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { AnyModel } from "@yaakapp-internal/models";
|
||||
import { patchModel } from "@yaakapp-internal/models";
|
||||
import { Icon } from "@yaakapp-internal/ui";
|
||||
import classNames from "classnames";
|
||||
import type { ReactNode } from "react";
|
||||
import { CopyIconButton } from "../CopyIconButton";
|
||||
@@ -139,6 +140,90 @@ export function SettingValue({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A command or config to copy, set as a block: its title, an optional line
|
||||
* saying which file it goes in, then the snippet at full width with the copy
|
||||
* button on it. One-line shell commands and multi-line JSON get the same block.
|
||||
*/
|
||||
export function SettingCommand({
|
||||
className,
|
||||
description,
|
||||
disabled,
|
||||
done,
|
||||
language,
|
||||
snippet,
|
||||
title,
|
||||
}: {
|
||||
description?: ReactNode;
|
||||
disabled?: boolean;
|
||||
/** A short word shown with a check beside the title once the step is detected as done */
|
||||
done?: ReactNode;
|
||||
language: SettingSnippetLanguage;
|
||||
snippet: string;
|
||||
title: ReactNode;
|
||||
} & Pick<SettingRowBaseProps, "className">) {
|
||||
return (
|
||||
<div
|
||||
aria-disabled={disabled || undefined}
|
||||
className={classNames(
|
||||
className,
|
||||
"border-b border-border-subtle py-4",
|
||||
disabled && "opacity-disabled",
|
||||
)}
|
||||
>
|
||||
<div className="flex min-w-0 items-center gap-2 text text-text">
|
||||
<span>{title}</span>
|
||||
{done != null && done !== false && (
|
||||
<span className="inline-flex items-center gap-1 text-sm text-success">
|
||||
<Icon icon="check" size="sm" />
|
||||
{done}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{description != null && (
|
||||
<div className="mt-1 max-w-2xl text-sm text-text-subtle">{description}</div>
|
||||
)}
|
||||
<SettingSnippet className="mt-3" language={language} snippet={snippet} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export type SettingSnippetLanguage = "shell" | "json" | "text";
|
||||
|
||||
/** The snippet half of a `SettingCommand`, for places with their own title, like a banner. */
|
||||
export function SettingSnippet({
|
||||
className,
|
||||
language,
|
||||
snippet,
|
||||
}: {
|
||||
className?: string;
|
||||
language: SettingSnippetLanguage;
|
||||
snippet: string;
|
||||
}) {
|
||||
const prompt = language === "shell";
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
className,
|
||||
"flex items-start gap-2 rounded-md border border-border-subtle bg-surface-highlight/40 py-1.5 pr-1.5 pl-3",
|
||||
)}
|
||||
>
|
||||
<div className="flex min-h-sm min-w-0 flex-1 items-center font-mono text-editor text-text">
|
||||
<span className="cursor-text select-text whitespace-pre-wrap [overflow-wrap:anywhere]">
|
||||
{prompt && (
|
||||
<span aria-hidden className="mr-2 select-none text-text-subtlest">
|
||||
$
|
||||
</span>
|
||||
)}
|
||||
{snippet}
|
||||
</span>
|
||||
</div>
|
||||
<CopyIconButton size="sm" variant="border" title="Copy" text={snippet} className="shrink-0" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
type SettingValueAction = {
|
||||
icon: IconButtonProps["icon"];
|
||||
onClick: () => void;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useQueries, useQuery } from "@tanstack/react-query";
|
||||
import type { Plugin } from "@yaakapp-internal/models";
|
||||
import { pluginsAtom } from "@yaakapp-internal/models";
|
||||
import type { PluginMetadata } from "@yaakapp-internal/plugins";
|
||||
@@ -24,6 +24,22 @@ export function usePluginInfo(id: string | null) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Every plugin with its metadata, once loaded; the ones still loading are left out. */
|
||||
export function usePluginInfos() {
|
||||
const plugins = useAtomValue(pluginsAtom);
|
||||
return useQueries({
|
||||
queries: plugins.map((plugin) => ({
|
||||
queryKey: pluginInfoKey(plugin.id, plugin),
|
||||
queryFn: () => rpc<PluginMetadata>("cmd_plugin_info", { id: plugin.id }),
|
||||
})),
|
||||
combine: (results) =>
|
||||
results.flatMap((result, i) => {
|
||||
const plugin = plugins[i];
|
||||
return result.data == null || plugin == null ? [] : [{ plugin, info: result.data }];
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export function invalidateAllPluginInfo() {
|
||||
queryClient.invalidateQueries({ queryKey: ["plugin_info"] }).catch(console.error);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { uninstallPlugin } from "@yaakapp-internal/plugins";
|
||||
import { InlineCode } from "@yaakapp-internal/ui";
|
||||
import { showConfirmDelete } from "../lib/confirm";
|
||||
import { minPromiseMillis } from "../lib/minPromiseMillis";
|
||||
|
||||
/** Confirms, then uninstalls. Null until there is a plugin to uninstall. */
|
||||
export function usePromptUninstallPlugin(pluginId: string | null, name: string) {
|
||||
const mut = useMutation({
|
||||
mutationKey: ["uninstall_plugin", pluginId],
|
||||
mutationFn: async () => {
|
||||
if (pluginId == null) return;
|
||||
|
||||
const confirmed = await showConfirmDelete({
|
||||
id: `uninstall-plugin-${pluginId}`,
|
||||
title: "Uninstall Plugin",
|
||||
confirmText: "Uninstall",
|
||||
description: (
|
||||
<>
|
||||
Permanently uninstall <InlineCode>{name}</InlineCode>?
|
||||
</>
|
||||
),
|
||||
});
|
||||
if (confirmed) {
|
||||
await minPromiseMillis(uninstallPlugin(pluginId), 700);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return pluginId == null ? null : mut;
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
import { describe, expect, test } from "vite-plus/test";
|
||||
import { AGENT_CLIENTS, appSetup, cliSetup } from "./agentSetup";
|
||||
|
||||
const URL = "http://127.0.0.1:64343/mcp";
|
||||
const TOKEN = "abc123";
|
||||
import { AGENT_CLIENTS, cliSetup, skillInstallCommand } from "./agentSetup";
|
||||
|
||||
describe("cliSetup", () => {
|
||||
test("uses each client's own add command", () => {
|
||||
expect(cliSetup("claude_code").snippet).toBe("claude mcp add yaak -- yaak mcp");
|
||||
expect(cliSetup("claude_code").snippet).toBe("claude mcp add -s user yaak -- yaak mcp");
|
||||
expect(cliSetup("codex").snippet).toBe("codex mcp add yaak -- yaak mcp");
|
||||
});
|
||||
|
||||
test("names a file only when the snippet goes in one", () => {
|
||||
expect(cliSetup("claude_code").where).toBeNull();
|
||||
expect(cliSetup("codex").where).toBeNull();
|
||||
expect(cliSetup("cursor").where).toBe("Add to ~/.cursor/mcp.json.");
|
||||
expect(cliSetup("vscode").where).toContain("mcp.json");
|
||||
expect(cliSetup("other").where).not.toBeNull();
|
||||
});
|
||||
|
||||
test("writes the config shape each client reads", () => {
|
||||
expect(JSON.parse(cliSetup("cursor").snippet)).toEqual({
|
||||
mcpServers: { yaak: { command: "yaak", args: ["mcp"] } },
|
||||
@@ -21,42 +26,27 @@ describe("cliSetup", () => {
|
||||
mcpServers: { yaak: { command: "yaak", args: ["mcp"] } },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("appSetup", () => {
|
||||
test("passes the token as a bearer header", () => {
|
||||
expect(appSetup("claude_code", URL, TOKEN).snippet).toBe(
|
||||
`claude mcp add --transport http yaak ${URL} --header "Authorization: Bearer ${TOKEN}"`,
|
||||
);
|
||||
expect(appSetup("codex", URL, TOKEN).snippet).toBe(
|
||||
`[mcp_servers.yaak]\nurl = "${URL}"\nhttp_headers = { "Authorization" = "Bearer ${TOKEN}" }`,
|
||||
);
|
||||
expect(JSON.parse(appSetup("cursor", URL, TOKEN).snippet)).toEqual({
|
||||
mcpServers: { yaak: { url: URL, headers: { Authorization: `Bearer ${TOKEN}` } } },
|
||||
});
|
||||
expect(JSON.parse(appSetup("vscode", URL, TOKEN).snippet)).toEqual({
|
||||
servers: { yaak: { type: "http", url: URL, headers: { Authorization: `Bearer ${TOKEN}` } } },
|
||||
});
|
||||
expect(JSON.parse(appSetup("other", URL, TOKEN).snippet)).toEqual({
|
||||
mcpServers: {
|
||||
yaak: {
|
||||
command: "npx",
|
||||
args: ["-y", "mcp-remote", URL, "--header", `Authorization: Bearer ${TOKEN}`],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("keeps argument lists on one line", () => {
|
||||
expect(appSetup("other", URL, TOKEN).snippet).toContain(
|
||||
`"args": ["-y", "mcp-remote", "${URL}", "--header", "Authorization: Bearer ${TOKEN}"]`,
|
||||
);
|
||||
expect(cliSetup("cursor").snippet).toContain(`"args": ["mcp"]`);
|
||||
});
|
||||
|
||||
test("covers every listed client", () => {
|
||||
for (const { value } of AGENT_CLIENTS) {
|
||||
expect(cliSetup(value).snippet).not.toBe("");
|
||||
expect(appSetup(value, URL, TOKEN).snippet).toContain(TOKEN);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("skillInstallCommand", () => {
|
||||
test("targets the agents the installer knows by name", () => {
|
||||
expect(skillInstallCommand("claude_code")).toBe("yaak agent install --agent claude-code");
|
||||
expect(skillInstallCommand("codex")).toBe("yaak agent install --agent codex");
|
||||
expect(skillInstallCommand("cursor")).toBe("yaak agent install --agent cursor");
|
||||
});
|
||||
|
||||
test("installs everywhere for agents it cannot target", () => {
|
||||
expect(skillInstallCommand("vscode")).toBe("yaak agent install");
|
||||
expect(skillInstallCommand("other")).toBe("yaak agent install");
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,6 @@
|
||||
export type AgentClient = "claude_code" | "codex" | "cursor" | "vscode" | "other";
|
||||
import type { AgentClient } from "@yaakapp-internal/rpc-schema";
|
||||
|
||||
export type { AgentClient };
|
||||
|
||||
export const AGENT_CLIENTS: { label: string; value: AgentClient }[] = [
|
||||
{ label: "Claude Code", value: "claude_code" },
|
||||
@@ -9,21 +11,34 @@ export const AGENT_CLIENTS: { label: string; value: AgentClient }[] = [
|
||||
];
|
||||
|
||||
export interface AgentSetup {
|
||||
/** Where the snippet goes, as a sentence */
|
||||
where: string;
|
||||
/** The file the snippet goes in, as a sentence, when it is a file rather than a command */
|
||||
where: string | null;
|
||||
snippet: string;
|
||||
language: "shell" | "json" | "text";
|
||||
}
|
||||
|
||||
const RUN_IN_TERMINAL = "Run in a terminal.";
|
||||
/** `yaak agent install`, targeted at `client` when the installer knows it by name. */
|
||||
export function skillInstallCommand(client: AgentClient): string {
|
||||
switch (client) {
|
||||
case "claude_code":
|
||||
return "yaak agent install --agent claude-code";
|
||||
case "codex":
|
||||
return "yaak agent install --agent codex";
|
||||
case "cursor":
|
||||
return "yaak agent install --agent cursor";
|
||||
case "vscode":
|
||||
case "other":
|
||||
return "yaak agent install";
|
||||
}
|
||||
}
|
||||
|
||||
/** Setup for `yaak mcp`, which the client launches over stdio. */
|
||||
export function cliSetup(client: AgentClient): AgentSetup {
|
||||
switch (client) {
|
||||
case "claude_code":
|
||||
return { where: RUN_IN_TERMINAL, snippet: "claude mcp add yaak -- yaak mcp", language: "shell" };
|
||||
return { where: null, snippet: "claude mcp add -s user yaak -- yaak mcp", language: "shell" };
|
||||
case "codex":
|
||||
return { where: RUN_IN_TERMINAL, snippet: "codex mcp add yaak -- yaak mcp", language: "shell" };
|
||||
return { where: null, snippet: "codex mcp add yaak -- yaak mcp", language: "shell" };
|
||||
case "cursor":
|
||||
return {
|
||||
where: "Add to ~/.cursor/mcp.json.",
|
||||
@@ -45,56 +60,6 @@ export function cliSetup(client: AgentClient): AgentSetup {
|
||||
}
|
||||
}
|
||||
|
||||
/** Setup for the app's MCP server at `url`, which needs `token` as a bearer token. */
|
||||
export function appSetup(client: AgentClient, url: string, token: string): AgentSetup {
|
||||
const authorization = `Bearer ${token}`;
|
||||
switch (client) {
|
||||
case "claude_code":
|
||||
return {
|
||||
where: RUN_IN_TERMINAL,
|
||||
snippet: `claude mcp add --transport http yaak ${url} --header "Authorization: ${authorization}"`,
|
||||
language: "shell",
|
||||
};
|
||||
case "codex":
|
||||
return {
|
||||
where: "Add to ~/.codex/config.toml.",
|
||||
snippet: [
|
||||
"[mcp_servers.yaak]",
|
||||
`url = ${JSON.stringify(url)}`,
|
||||
`http_headers = { "Authorization" = ${JSON.stringify(authorization)} }`,
|
||||
].join("\n"),
|
||||
language: "text",
|
||||
};
|
||||
case "cursor":
|
||||
return {
|
||||
where: "Add to ~/.cursor/mcp.json.",
|
||||
snippet: json({ mcpServers: { yaak: { url, headers: { Authorization: authorization } } } }),
|
||||
language: "json",
|
||||
};
|
||||
case "vscode":
|
||||
return {
|
||||
where: "Add to your user mcp.json (MCP: Open User Configuration).",
|
||||
snippet: json({
|
||||
servers: { yaak: { type: "http", url, headers: { Authorization: authorization } } },
|
||||
}),
|
||||
language: "json",
|
||||
};
|
||||
case "other":
|
||||
return {
|
||||
where: "For clients that read an mcpServers config, through the mcp-remote bridge.",
|
||||
snippet: json({
|
||||
mcpServers: {
|
||||
yaak: {
|
||||
command: "npx",
|
||||
args: ["-y", "mcp-remote", url, "--header", `Authorization: ${authorization}`],
|
||||
},
|
||||
},
|
||||
}),
|
||||
language: "json",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/** Pretty JSON with arrays of plain values kept on one line. */
|
||||
function json(value: unknown): string {
|
||||
return JSON.stringify(value, null, 2).replace(
|
||||
|
||||
@@ -93,8 +93,23 @@ pub enum Commands {
|
||||
/// Response commands
|
||||
Response(ResponseArgs),
|
||||
|
||||
/// Serve Yaak's MCP tools over stdio, for AI agents like Claude Code
|
||||
Mcp,
|
||||
/// Serve Yaak's MCP tools to AI agents like Claude Code, over stdio or with --http
|
||||
Mcp(McpArgs),
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct McpArgs {
|
||||
/// Serve over HTTP on 127.0.0.1 instead of stdio, for agents that cannot run this command
|
||||
#[arg(long)]
|
||||
pub http: bool,
|
||||
|
||||
/// Port to listen on with --http
|
||||
#[arg(long, default_value_t = yaak_mcp::http::DEFAULT_PORT, requires = "http")]
|
||||
pub port: u16,
|
||||
|
||||
/// Bearer token clients must send with --http; generated and printed when omitted
|
||||
#[arg(long, requires = "http", value_name = "TOKEN")]
|
||||
pub token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use crate::cli::McpArgs;
|
||||
use crate::context::{CliContext, CliExecutionContext};
|
||||
use crate::plugin_events::SendContexts;
|
||||
use rand::Rng;
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use yaak::send::{SendHttpRequestWithPluginsParams, send_http_request_with_plugins};
|
||||
@@ -13,7 +16,27 @@ use yaak_models::util::UpdateSource;
|
||||
use yaak_plugins::events::{PluginContext, ShowToastRequest};
|
||||
use yaak_plugins::manager::PluginManager;
|
||||
|
||||
pub async fn run(ctx: &CliContext, environment: Option<&str>, cookie_jar_id: Option<&str>) -> i32 {
|
||||
enum Transport {
|
||||
Stdio,
|
||||
Http { port: u16, token: Option<String> },
|
||||
}
|
||||
|
||||
impl From<McpArgs> for Transport {
|
||||
fn from(args: McpArgs) -> Self {
|
||||
if args.http {
|
||||
Transport::Http { port: args.port, token: args.token }
|
||||
} else {
|
||||
Transport::Stdio
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run(
|
||||
ctx: &CliContext,
|
||||
args: McpArgs,
|
||||
environment: Option<&str>,
|
||||
cookie_jar_id: Option<&str>,
|
||||
) -> i32 {
|
||||
let host = CliMcpHost {
|
||||
query_manager: ctx.query_manager().clone(),
|
||||
blob_manager: ctx.blob_manager().clone(),
|
||||
@@ -25,7 +48,11 @@ pub async fn run(ctx: &CliContext, environment: Option<&str>, cookie_jar_id: Opt
|
||||
environment_id: environment.map(str::to_string),
|
||||
cookie_jar_id: cookie_jar_id.map(str::to_string),
|
||||
};
|
||||
match yaak_mcp::serve_stdio(host).await {
|
||||
let result = match Transport::from(args) {
|
||||
Transport::Stdio => yaak_mcp::serve_stdio(host).await,
|
||||
Transport::Http { port, token } => serve_http(host, port, token).await,
|
||||
};
|
||||
match result {
|
||||
Ok(()) => 0,
|
||||
Err(error) => {
|
||||
eprintln!("Error: {error}");
|
||||
@@ -34,6 +61,24 @@ pub async fn run(ctx: &CliContext, environment: Option<&str>, cookie_jar_id: Opt
|
||||
}
|
||||
}
|
||||
|
||||
async fn serve_http(host: CliMcpHost, port: u16, token: Option<String>) -> Result<(), String> {
|
||||
let token = token.unwrap_or_else(generate_token);
|
||||
let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, port));
|
||||
let server = yaak_mcp::http::serve(Arc::new(host), addr, token.clone())
|
||||
.await
|
||||
.map_err(|e| format!("Failed to start MCP server on {addr}: {e}"))?;
|
||||
eprintln!("Yaak MCP server listening on http://{}{}", server.addr, yaak_mcp::http::PATH);
|
||||
eprintln!("Token: {token}");
|
||||
eprintln!("Clients must send it as \"Authorization: Bearer <token>\". Press Ctrl+C to stop.");
|
||||
tokio::signal::ctrl_c().await.map_err(|e| format!("Failed to wait for Ctrl+C: {e}"))?;
|
||||
server.stop().await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn generate_token() -> String {
|
||||
hex::encode(rand::thread_rng().r#gen::<[u8; 32]>())
|
||||
}
|
||||
|
||||
/// Every workspace in the database is "open", and the global `--environment`
|
||||
/// and `--cookie-jar` flags stand in for a window's selection.
|
||||
struct CliMcpHost {
|
||||
|
||||
@@ -184,7 +184,7 @@ async fn main() {
|
||||
context.shutdown().await;
|
||||
exit_code
|
||||
}
|
||||
Commands::Mcp => {
|
||||
Commands::Mcp(args) => {
|
||||
let mut context = CliContext::new(data_dir.clone(), app_id);
|
||||
context
|
||||
.init_plugins(CliExecutionContext {
|
||||
@@ -194,7 +194,8 @@ async fn main() {
|
||||
})
|
||||
.await;
|
||||
let exit_code =
|
||||
commands::mcp::run(&context, environment.as_deref(), cookie_jar.as_deref()).await;
|
||||
commands::mcp::run(&context, args, environment.as_deref(), cookie_jar.as_deref())
|
||||
.await;
|
||||
context.shutdown().await;
|
||||
exit_code
|
||||
}
|
||||
|
||||
@@ -222,3 +222,129 @@ async fn mcp_send_settings_reach_template_functions() {
|
||||
client.cancel().await.unwrap();
|
||||
assert!(child.wait().await.unwrap().success());
|
||||
}
|
||||
|
||||
/// Spawns `yaak mcp --http` with `args` and returns the child, the URL it
|
||||
/// printed, and the token it printed or was given.
|
||||
async fn spawn_http(data_dir: &std::path::Path, args: &[&str]) -> (tokio::process::Child, String, String) {
|
||||
use tokio::io::AsyncBufReadExt;
|
||||
|
||||
let mut child = Command::new(env!("CARGO_BIN_EXE_yaak"))
|
||||
.arg("--data-dir")
|
||||
.arg(data_dir)
|
||||
.args(["mcp", "--http", "--port", "0"])
|
||||
.args(args)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::piped())
|
||||
.kill_on_drop(true)
|
||||
.spawn()
|
||||
.unwrap();
|
||||
let mut stderr = tokio::io::BufReader::new(child.stderr.take().unwrap()).lines();
|
||||
let mut url = None;
|
||||
let mut token = None;
|
||||
while url.is_none() || token.is_none() {
|
||||
let line = stderr.next_line().await.unwrap().expect("server exited before announcing");
|
||||
if let Some(rest) = line.strip_prefix("Yaak MCP server listening on ") {
|
||||
url = Some(rest.to_string());
|
||||
} else if let Some(rest) = line.strip_prefix("Token: ") {
|
||||
token = Some(rest.to_string());
|
||||
}
|
||||
}
|
||||
(child, url.unwrap(), token.unwrap())
|
||||
}
|
||||
|
||||
/// Posts one JSON-RPC message, with the session id when there is one, and
|
||||
/// returns the response and its body parsed out of either JSON or SSE.
|
||||
async fn post(
|
||||
client: &reqwest::Client,
|
||||
url: &str,
|
||||
auth: Option<&str>,
|
||||
session: Option<&str>,
|
||||
body: Value,
|
||||
) -> (reqwest::StatusCode, reqwest::header::HeaderMap, Option<Value>) {
|
||||
let mut request = client
|
||||
.post(url)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept", "application/json, text/event-stream")
|
||||
.body(body.to_string());
|
||||
if let Some(auth) = auth {
|
||||
request = request.header("Authorization", auth);
|
||||
}
|
||||
if let Some(session) = session {
|
||||
request = request.header("Mcp-Session-Id", session);
|
||||
}
|
||||
let response = request.send().await.unwrap();
|
||||
let status = response.status();
|
||||
let headers = response.headers().clone();
|
||||
let text = response.text().await.unwrap();
|
||||
let message = text
|
||||
.lines()
|
||||
.filter_map(|l| l.strip_prefix("data:"))
|
||||
.last()
|
||||
.map(str::trim)
|
||||
.unwrap_or(text.trim());
|
||||
(status, headers, serde_json::from_str(message).ok())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_http_requires_the_token() {
|
||||
let temp_dir = TempDir::new().expect("Failed to create temp dir");
|
||||
let data_dir = temp_dir.path();
|
||||
seed_workspace(data_dir, "wk_test");
|
||||
let (mut child, url, token) = spawn_http(data_dir, &["--token", "s3cret"]).await;
|
||||
assert_eq!(token, "s3cret");
|
||||
assert!(url.starts_with("http://127.0.0.1:"), "{url}");
|
||||
assert!(url.ends_with("/mcp"), "{url}");
|
||||
let client = reqwest::Client::new();
|
||||
let initialize = json!({
|
||||
"jsonrpc": "2.0", "id": 1, "method": "initialize",
|
||||
"params": { "protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": { "name": "test", "version": "1.0" } }
|
||||
});
|
||||
|
||||
for auth in [None, Some("Bearer wrong")] {
|
||||
let (status, headers, _) = post(&client, &url, auth, None, initialize.clone()).await;
|
||||
assert_eq!(status, reqwest::StatusCode::UNAUTHORIZED, "{auth:?}");
|
||||
assert_eq!(headers["www-authenticate"], "Bearer");
|
||||
}
|
||||
|
||||
let auth = Some("Bearer s3cret");
|
||||
let (status, headers, body) = post(&client, &url, auth, None, initialize).await;
|
||||
assert_eq!(status, reqwest::StatusCode::OK);
|
||||
let session = headers["mcp-session-id"].to_str().unwrap().to_string();
|
||||
assert_eq!(body.unwrap()["result"]["serverInfo"]["name"], "yaak-mcp-server");
|
||||
|
||||
let initialized = json!({ "jsonrpc": "2.0", "method": "notifications/initialized" });
|
||||
let (status, _, _) = post(&client, &url, auth, Some(&session), initialized).await;
|
||||
assert_eq!(status, reqwest::StatusCode::ACCEPTED);
|
||||
|
||||
let list = json!({ "jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {} });
|
||||
let (status, _, body) = post(&client, &url, auth, Some(&session), list).await;
|
||||
assert_eq!(status, reqwest::StatusCode::OK);
|
||||
let tools = body.unwrap()["result"]["tools"].as_array().unwrap().len();
|
||||
assert_eq!(tools, 15);
|
||||
|
||||
child.kill().await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_http_generates_a_token() {
|
||||
let temp_dir = TempDir::new().expect("Failed to create temp dir");
|
||||
let data_dir = temp_dir.path();
|
||||
seed_workspace(data_dir, "wk_test");
|
||||
let (mut child, url, token) = spawn_http(data_dir, &[]).await;
|
||||
assert_eq!(token.len(), 64, "{token}");
|
||||
assert!(token.chars().all(|c| c.is_ascii_hexdigit()), "{token}");
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let initialize = json!({
|
||||
"jsonrpc": "2.0", "id": 1, "method": "initialize",
|
||||
"params": { "protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": { "name": "test", "version": "1.0" } }
|
||||
});
|
||||
let (status, _, _) = post(&client, &url, None, None, initialize.clone()).await;
|
||||
assert_eq!(status, reqwest::StatusCode::UNAUTHORIZED);
|
||||
let (status, _, _) =
|
||||
post(&client, &url, Some(&format!("Bearer {token}")), None, initialize).await;
|
||||
assert_eq!(status, reqwest::StatusCode::OK);
|
||||
|
||||
child.kill().await.unwrap();
|
||||
}
|
||||
@@ -62,7 +62,6 @@ mod grpc;
|
||||
mod history;
|
||||
mod http_request;
|
||||
mod import;
|
||||
mod mcp_ext;
|
||||
mod models_ext;
|
||||
mod notifications;
|
||||
mod plugin_events;
|
||||
@@ -1362,7 +1361,6 @@ pub fn run() {
|
||||
app.app_handle().set_native_titlebar(settings.use_native_titlebar);
|
||||
|
||||
monitor_plugin_events(&app.app_handle().clone());
|
||||
mcp_ext::init(app.app_handle());
|
||||
|
||||
Ok(())
|
||||
})
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
//! The built-in MCP server: `yaak_mcp`'s tools on 127.0.0.1:64343, served
|
||||
//! while the `mcpServerEnabled` setting is on, behind a bearer token kept in
|
||||
//! key_values.
|
||||
|
||||
use crate::models_ext::QueryManagerExt;
|
||||
use crate::plugin_events::send_http_request_in_window;
|
||||
use crate::{environment_from_window, workspace_from_window};
|
||||
use log::{error, info};
|
||||
use rand::Rng;
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
use std::sync::Arc;
|
||||
use tauri::{AppHandle, Emitter, Manager, Runtime, WebviewWindow};
|
||||
use tokio::sync::Mutex;
|
||||
use yaak_mcp::http::{DEFAULT_PORT, HttpServer};
|
||||
use yaak_mcp::{HostResult, McpHost, WorkspaceInfo};
|
||||
use yaak_models::models::{Folder, HttpRequest, HttpResponse};
|
||||
use yaak_models::util::UpdateSource;
|
||||
use yaak_plugins::events::{Color, PluginContext, ShowToastRequest};
|
||||
|
||||
pub(crate) const TOKEN_NAMESPACE: &str = "no_sync";
|
||||
pub(crate) const TOKEN_KEY: &str = "mcp_server_token";
|
||||
|
||||
#[derive(Default)]
|
||||
struct McpServerState(Mutex<Option<HttpServer>>);
|
||||
|
||||
pub(crate) fn init<R: Runtime>(app_handle: &AppHandle<R>) {
|
||||
app_handle.manage(McpServerState::default());
|
||||
sync(app_handle);
|
||||
}
|
||||
|
||||
/// Start or stop the server to match the setting.
|
||||
pub(crate) fn sync<R: Runtime>(app_handle: &AppHandle<R>) {
|
||||
let app_handle = app_handle.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let Some(state) = app_handle.try_state::<McpServerState>() else {
|
||||
return;
|
||||
};
|
||||
let mut server = state.0.lock().await;
|
||||
let enabled = app_handle.db().get_settings().mcp_server_enabled;
|
||||
match (enabled, server.is_some()) {
|
||||
(true, false) => match start(&app_handle).await {
|
||||
Ok(s) => {
|
||||
info!("MCP server listening on http://{}{}", s.addr, yaak_mcp::http::PATH);
|
||||
*server = Some(s);
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to start MCP server: {e}");
|
||||
let _ = app_handle.emit(
|
||||
"show_toast",
|
||||
ShowToastRequest {
|
||||
message: format!(
|
||||
"Failed to start the MCP server on port {DEFAULT_PORT}: {e}"
|
||||
),
|
||||
color: Some(Color::Danger),
|
||||
timeout: Some(10000),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
(false, true) => {
|
||||
if let Some(s) = server.take() {
|
||||
s.stop().await;
|
||||
info!("MCP server stopped");
|
||||
}
|
||||
}
|
||||
(true, true) | (false, false) => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async fn start<R: Runtime>(app_handle: &AppHandle<R>) -> std::io::Result<HttpServer> {
|
||||
let host = Arc::new(AppMcpHost { app_handle: app_handle.clone() });
|
||||
let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, DEFAULT_PORT));
|
||||
yaak_mcp::http::serve(host, addr, token(app_handle)).await
|
||||
}
|
||||
|
||||
/// The token, generated the first time the server starts.
|
||||
fn token<R: Runtime>(app_handle: &AppHandle<R>) -> String {
|
||||
let existing = app_handle.db().get_key_value_str(TOKEN_NAMESPACE, TOKEN_KEY, "");
|
||||
if !existing.is_empty() {
|
||||
return existing;
|
||||
}
|
||||
let mut rng = rand::rng();
|
||||
let token: String = (0..32).map(|_| format!("{:02x}", rng.random::<u8>())).collect();
|
||||
if let Err(e) = app_handle.with_tx(|tx| {
|
||||
tx.set_key_value_str(TOKEN_NAMESPACE, TOKEN_KEY, &token, &UpdateSource::Background);
|
||||
Ok(())
|
||||
}) {
|
||||
error!("Failed to save MCP server token: {e}");
|
||||
}
|
||||
token
|
||||
}
|
||||
|
||||
struct AppMcpHost<R: Runtime> {
|
||||
app_handle: AppHandle<R>,
|
||||
}
|
||||
|
||||
impl<R: Runtime> AppMcpHost<R> {
|
||||
fn window_for_workspace(&self, workspace_id: &str) -> Option<WebviewWindow<R>> {
|
||||
self.app_handle
|
||||
.webview_windows()
|
||||
.into_values()
|
||||
.find(|w| workspace_from_window(w).is_some_and(|ws| ws.id == workspace_id))
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: Runtime> McpHost for AppMcpHost<R> {
|
||||
fn list_workspaces(&self) -> HostResult<Vec<WorkspaceInfo>> {
|
||||
let mut workspaces: Vec<WorkspaceInfo> = Vec::new();
|
||||
for window in self.app_handle.webview_windows().values() {
|
||||
if let Some(w) = workspace_from_window(window)
|
||||
&& !workspaces.iter().any(|existing| existing.id == w.id)
|
||||
{
|
||||
workspaces.push(WorkspaceInfo { id: w.id, name: w.name });
|
||||
}
|
||||
}
|
||||
Ok(workspaces)
|
||||
}
|
||||
|
||||
fn active_environment_id(&self, workspace_id: &str) -> HostResult<Option<String>> {
|
||||
Ok(self
|
||||
.window_for_workspace(workspace_id)
|
||||
.and_then(|w| environment_from_window(&w))
|
||||
.map(|e| e.id))
|
||||
}
|
||||
|
||||
fn list_http_requests(&self, workspace_id: &str) -> HostResult<Vec<HttpRequest>> {
|
||||
self.app_handle.db().list_http_requests(workspace_id).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
fn get_http_request(&self, id: &str) -> HostResult<Option<HttpRequest>> {
|
||||
Ok(self.app_handle.db().get_http_request(id).ok())
|
||||
}
|
||||
|
||||
fn upsert_http_request(&self, request: &HttpRequest) -> HostResult<HttpRequest> {
|
||||
self.app_handle
|
||||
.with_tx(|tx| tx.upsert_http_request(request, &UpdateSource::Plugin))
|
||||
.map_err(|e| format!("Failed to upsert HTTP request: {e}"))
|
||||
}
|
||||
|
||||
fn delete_http_request(&self, id: &str) -> HostResult<HttpRequest> {
|
||||
self.app_handle
|
||||
.with_tx(|tx| tx.delete_http_request_by_id(id, &UpdateSource::Plugin))
|
||||
.map_err(|e| format!("Failed to delete HTTP request: {e}"))
|
||||
}
|
||||
|
||||
fn list_folders(&self, workspace_id: &str) -> HostResult<Vec<Folder>> {
|
||||
self.app_handle.db().list_folders(workspace_id).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
fn upsert_folder(&self, folder: &Folder) -> HostResult<Folder> {
|
||||
self.app_handle
|
||||
.with_tx(|tx| tx.upsert_folder(folder, &UpdateSource::Plugin))
|
||||
.map_err(|e| format!("Failed to upsert folder: {e}"))
|
||||
}
|
||||
|
||||
fn delete_folder(&self, id: &str) -> HostResult<Folder> {
|
||||
self.app_handle
|
||||
.with_tx(|tx| tx.delete_folder_by_id(id, &UpdateSource::Plugin))
|
||||
.map_err(|e| format!("Failed to delete folder: {e}"))
|
||||
}
|
||||
|
||||
async fn send_http_request(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
request: HttpRequest,
|
||||
environment_id: Option<String>,
|
||||
) -> HostResult<HttpResponse> {
|
||||
let window = self
|
||||
.window_for_workspace(workspace_id)
|
||||
.ok_or_else(|| format!("No window is open for workspace {workspace_id}"))?;
|
||||
let plugin_context = PluginContext {
|
||||
label: Some(window.label().to_string()),
|
||||
workspace_id: Some(workspace_id.to_string()),
|
||||
..PluginContext::new_empty()
|
||||
};
|
||||
let sent = send_http_request_in_window(
|
||||
&window,
|
||||
request,
|
||||
environment_id.as_deref(),
|
||||
&plugin_context,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(sent.response)
|
||||
}
|
||||
|
||||
fn show_toast(&self, toast: ShowToastRequest) -> HostResult<()> {
|
||||
self.app_handle.emit("show_toast", toast).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ use tauri_plugin_dialog::{DialogExt, MessageDialogKind};
|
||||
use yaak_models::blob_manager::BlobManager;
|
||||
use yaak_models::client_db::{ClientDb, WriteDb};
|
||||
use yaak_models::error::Result;
|
||||
use yaak_models::models::AnyModel;
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_models::util::{ModelPayload, UpdateSource};
|
||||
|
||||
@@ -175,20 +174,15 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
std::thread::spawn(move || {
|
||||
while let Ok(payload) = rx.recv() {
|
||||
let mut batch: Vec<ModelPayload> = Vec::new();
|
||||
let mut settings_changed = matches!(payload.model, AnyModel::Settings(_));
|
||||
if matches!(payload.update_source, UpdateSource::Window { .. }) {
|
||||
batch.push(payload);
|
||||
}
|
||||
// Coalesce any writes already queued into the same emit
|
||||
while let Ok(next) = rx.try_recv() {
|
||||
settings_changed |= matches!(next.model, AnyModel::Settings(_));
|
||||
if matches!(next.update_source, UpdateSource::Window { .. }) {
|
||||
batch.push(next);
|
||||
}
|
||||
}
|
||||
if settings_changed {
|
||||
crate::mcp_ext::sync(&app_handle_local);
|
||||
}
|
||||
if batch.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -391,6 +391,14 @@ async fn cmd_metadata<R: Runtime>(ctx: ClientCtx<R>, _req: CmdMetadataReq) -> Re
|
||||
Ok(crate::cmd_metadata(ctx.window.app_handle().clone()).await?)
|
||||
}
|
||||
|
||||
async fn cmd_agent_setup_status<R: Runtime>(
|
||||
ctx: ClientCtx<R>,
|
||||
req: CmdAgentSetupStatusReq,
|
||||
) -> Result<AgentSetupStatus> {
|
||||
let home = ctx.window.app_handle().path().home_dir()?;
|
||||
Ok(yaak_commands::agents::agent_setup_status(&home, req.agent))
|
||||
}
|
||||
|
||||
async fn cmd_template_tokens_to_string<R: Runtime>(
|
||||
ctx: ClientCtx<R>,
|
||||
req: CmdTemplateTokensToStringReq,
|
||||
|
||||
+14
-1
@@ -10,11 +10,24 @@ import type { BatchUpsertResult, ImportDestination, ImportPlan } from "./gen_uti
|
||||
import type { Tokens } from "./parser";
|
||||
import type { ServerSentEvent } from "./sse";
|
||||
|
||||
/**
|
||||
* A coding agent the Agents settings pane can set up.
|
||||
*/
|
||||
export type AgentClient = "claude_code" | "codex" | "cursor" | "vscode" | "other";
|
||||
|
||||
/**
|
||||
* Which setup steps an agent already has done on this machine. `None` means
|
||||
* the pane cannot tell for that agent.
|
||||
*/
|
||||
export type AgentSetupStatus = { mcpServer: boolean | null, skill: boolean | null, };
|
||||
|
||||
/**
|
||||
* What the frontend learns about the host it is talking to.
|
||||
*/
|
||||
export type AppMetaData = { isDev: boolean, version: string, cliVersion: string | null, name: string, appDataDir: string, appLogDir: string, vendoredPluginDir: string, defaultProjectDir: string, featureUpdater: boolean, featureLicense: boolean, };
|
||||
|
||||
export type CmdAgentSetupStatusReq = { agent: AgentClient, };
|
||||
|
||||
export type CmdCallFolderActionReq = { req: CallFolderActionRequest, };
|
||||
|
||||
export type CmdCallGrpcRequestActionReq = { req: CallGrpcRequestActionRequest, };
|
||||
@@ -256,6 +269,6 @@ export type ModelsWebsocketEventsReq = { connectionId: string, };
|
||||
|
||||
export type ModelsWorkspaceModelsReq = { workspaceId: string | null, };
|
||||
|
||||
export type RpcSchema = { cmd_metadata: [CmdMetadataReq, AppMetaData], cmd_template_tokens_to_string: [CmdTemplateTokensToStringReq, string], cmd_render_template: [CmdRenderTemplateReq, string], cmd_send_feedback: [CmdSendFeedbackReq, null], cmd_dismiss_notification: [CmdDismissNotificationReq, null], cmd_grpc_reflect: [CmdGrpcReflectReq, Array<ServiceDefinition>], cmd_grpc_go: [CmdGrpcGoReq, string], cmd_restart: [CmdRestartReq, null], cmd_send_ephemeral_request: [CmdSendEphemeralRequestReq, EphemeralHttpResponse], cmd_format_json: [CmdFormatJsonReq, string], cmd_format_graphql: [CmdFormatGraphqlReq, string], cmd_http_response_body: [CmdHttpResponseBodyReq, FilterResponse], cmd_http_response_body_path: [CmdHttpResponseBodyPathReq, string | null], cmd_http_request_body: [CmdHttpRequestBodyReq, Array<number> | null], cmd_get_sse_events: [CmdGetSseEventsReq, Array<ServerSentEvent>], cmd_get_http_response_events: [CmdGetHttpResponseEventsReq, Array<HttpResponseEvent>], cmd_import_data: [CmdImportDataReq, ImportPlan], cmd_commit_import: [CmdCommitImportReq, BatchUpsertResult], cmd_list_import_sources: [CmdListImportSourcesReq, Array<ImportSource>], cmd_import_sources_for_origin: [CmdImportSourcesForOriginReq, Array<ImportSource>], cmd_detect_import_source: [CmdDetectImportSourceReq, string], cmd_http_request_actions: [CmdHttpRequestActionsReq, Array<GetHttpRequestActionsResponse>], cmd_websocket_request_actions: [CmdWebsocketRequestActionsReq, Array<GetWebsocketRequestActionsResponse>], cmd_call_websocket_request_action: [CmdCallWebsocketRequestActionReq, null], cmd_workspace_actions: [CmdWorkspaceActionsReq, Array<GetWorkspaceActionsResponse>], cmd_call_workspace_action: [CmdCallWorkspaceActionReq, null], cmd_folder_actions: [CmdFolderActionsReq, Array<GetFolderActionsResponse>], cmd_call_folder_action: [CmdCallFolderActionReq, null], cmd_grpc_request_actions: [CmdGrpcRequestActionsReq, Array<GetGrpcRequestActionsResponse>], cmd_template_function_summaries: [CmdTemplateFunctionSummariesReq, Array<GetTemplateFunctionSummaryResponse>], cmd_template_function_config: [CmdTemplateFunctionConfigReq, GetTemplateFunctionConfigResponse], cmd_get_http_authentication_summaries: [CmdGetHttpAuthenticationSummariesReq, Array<GetHttpAuthenticationSummaryResponse>], cmd_get_http_authentication_config: [CmdGetHttpAuthenticationConfigReq, GetHttpAuthenticationConfigResponse], cmd_call_http_request_action: [CmdCallHttpRequestActionReq, null], cmd_call_grpc_request_action: [CmdCallGrpcRequestActionReq, null], cmd_call_http_authentication_action: [CmdCallHttpAuthenticationActionReq, null], cmd_curl_to_request: [CmdCurlToRequestReq, HttpRequest], cmd_export_data: [CmdExportDataReq, string], cmd_create_example_workspace: [CmdCreateExampleWorkspaceReq, BatchUpsertResult], cmd_save_base64_to_binary: [CmdSaveBase64ToBinaryReq, null], cmd_save_response: [CmdSaveResponseReq, null], cmd_send_http_request: [CmdSendHttpRequestReq, HttpResponse], cmd_reload_plugins: [CmdReloadPluginsReq, Array<[string, string]>], cmd_plugin_info: [CmdPluginInfoReq, PluginMetadata], cmd_delete_all_grpc_connections: [CmdDeleteAllGrpcConnectionsReq, null], cmd_delete_send_history: [CmdDeleteSendHistoryReq, null], cmd_delete_all_http_responses: [CmdDeleteAllHttpResponsesReq, null], cmd_get_workspace_meta: [CmdGetWorkspaceMetaReq, WorkspaceMeta], cmd_new_child_window: [CmdNewChildWindowReq, null], cmd_new_main_window: [CmdNewMainWindowReq, null], cmd_check_for_updates: [CmdCheckForUpdatesReq, boolean], cmd_decrypt_template: [CmdDecryptTemplateReq, string], cmd_secure_template: [CmdSecureTemplateReq, string], cmd_get_themes: [CmdGetThemesReq, Array<GetThemesResponse>], cmd_enable_encryption: [CmdEnableEncryptionReq, null], cmd_reveal_workspace_key: [CmdRevealWorkspaceKeyReq, string], cmd_set_workspace_key: [CmdSetWorkspaceKeyReq, null], cmd_disable_encryption: [CmdDisableEncryptionReq, null], cmd_default_headers: [CmdDefaultHeadersReq, Array<HttpRequestHeader>], models_upsert: [ModelsUpsertReq, string], models_delete: [ModelsDeleteReq, string], models_duplicate: [ModelsDuplicateReq, string], models_websocket_events: [ModelsWebsocketEventsReq, Array<WebsocketEvent>], models_grpc_events: [ModelsGrpcEventsReq, Array<GrpcEvent>], models_get_settings: [ModelsGetSettingsReq, Settings], models_get_graphql_introspection: [ModelsGetGraphqlIntrospectionReq, GraphQlIntrospection | null], models_upsert_graphql_introspection: [ModelsUpsertGraphqlIntrospectionReq, GraphQlIntrospection], models_workspace_models: [ModelsWorkspaceModelsReq, string], cmd_git_checkout: [CmdGitCheckoutReq, string], cmd_git_branch: [CmdGitBranchReq, null], cmd_git_delete_branch: [CmdGitDeleteBranchReq, BranchDeleteResult], cmd_git_delete_remote_branch: [CmdGitDeleteRemoteBranchReq, null], cmd_git_merge_branch: [CmdGitMergeBranchReq, null], cmd_git_rename_branch: [CmdGitRenameBranchReq, null], cmd_git_status: [CmdGitStatusReq, GitStatusSummary], cmd_git_branch_info: [CmdGitBranchInfoReq, GitBranchInfoLine truncated
|
||||
export type RpcSchema = { cmd_metadata: [CmdMetadataReq, AppMetaData], cmd_agent_setup_status: [CmdAgentSetupStatusReq, AgentSetupStatus], cmd_template_tokens_to_string: [CmdTemplateTokensToStringReq, string], cmd_render_template: [CmdRenderTemplateReq, string], cmd_send_feedback: [CmdSendFeedbackReq, null], cmd_dismiss_notification: [CmdDismissNotificationReq, null], cmd_grpc_reflect: [CmdGrpcReflectReq, Array<ServiceDefinition>], cmd_grpc_go: [CmdGrpcGoReq, string], cmd_restart: [CmdRestartReq, null], cmd_send_ephemeral_request: [CmdSendEphemeralRequestReq, EphemeralHttpResponse], cmd_format_json: [CmdFormatJsonReq, string], cmd_format_graphql: [CmdFormatGraphqlReq, string], cmd_http_response_body: [CmdHttpResponseBodyReq, FilterResponse], cmd_http_response_body_path: [CmdHttpResponseBodyPathReq, string | null], cmd_http_request_body: [CmdHttpRequestBodyReq, Array<number> | null], cmd_get_sse_events: [CmdGetSseEventsReq, Array<ServerSentEvent>], cmd_get_http_response_events: [CmdGetHttpResponseEventsReq, Array<HttpResponseEvent>], cmd_import_data: [CmdImportDataReq, ImportPlan], cmd_commit_import: [CmdCommitImportReq, BatchUpsertResult], cmd_list_import_sources: [CmdListImportSourcesReq, Array<ImportSource>], cmd_import_sources_for_origin: [CmdImportSourcesForOriginReq, Array<ImportSource>], cmd_detect_import_source: [CmdDetectImportSourceReq, string], cmd_http_request_actions: [CmdHttpRequestActionsReq, Array<GetHttpRequestActionsResponse>], cmd_websocket_request_actions: [CmdWebsocketRequestActionsReq, Array<GetWebsocketRequestActionsResponse>], cmd_call_websocket_request_action: [CmdCallWebsocketRequestActionReq, null], cmd_workspace_actions: [CmdWorkspaceActionsReq, Array<GetWorkspaceActionsResponse>], cmd_call_workspace_action: [CmdCallWorkspaceActionReq, null], cmd_folder_actions: [CmdFolderActionsReq, Array<GetFolderActionsResponse>], cmd_call_folder_action: [CmdCallFolderActionReq, null], cmd_grpc_request_actions: [CmdGrpcRequestActionsReq, Array<GetGrpcRequestActionsResponse>], cmd_template_function_summaries: [CmdTemplateFunctionSummariesReq, Array<GetTemplateFunctionSummaryResponse>], cmd_template_function_config: [CmdTemplateFunctionConfigReq, GetTemplateFunctionConfigResponse], cmd_get_http_authentication_summaries: [CmdGetHttpAuthenticationSummariesReq, Array<GetHttpAuthenticationSummaryResponse>], cmd_get_http_authentication_config: [CmdGetHttpAuthenticationConfigReq, GetHttpAuthenticationConfigResponse], cmd_call_http_request_action: [CmdCallHttpRequestActionReq, null], cmd_call_grpc_request_action: [CmdCallGrpcRequestActionReq, null], cmd_call_http_authentication_action: [CmdCallHttpAuthenticationActionReq, null], cmd_curl_to_request: [CmdCurlToRequestReq, HttpRequest], cmd_export_data: [CmdExportDataReq, string], cmd_create_example_workspace: [CmdCreateExampleWorkspaceReq, BatchUpsertResult], cmd_save_base64_to_binary: [CmdSaveBase64ToBinaryReq, null], cmd_save_response: [CmdSaveResponseReq, null], cmd_send_http_request: [CmdSendHttpRequestReq, HttpResponse], cmd_reload_plugins: [CmdReloadPluginsReq, Array<[string, string]>], cmd_plugin_info: [CmdPluginInfoReq, PluginMetadata], cmd_delete_all_grpc_connections: [CmdDeleteAllGrpcConnectionsReq, null], cmd_delete_send_history: [CmdDeleteSendHistoryReq, null], cmd_delete_all_http_responses: [CmdDeleteAllHttpResponsesReq, null], cmd_get_workspace_meta: [CmdGetWorkspaceMetaReq, WorkspaceMeta], cmd_new_child_window: [CmdNewChildWindowReq, null], cmd_new_main_window: [CmdNewMainWindowReq, null], cmd_check_for_updates: [CmdCheckForUpdatesReq, boolean], cmd_decrypt_template: [CmdDecryptTemplateReq, string], cmd_secure_template: [CmdSecureTemplateReq, string], cmd_get_themes: [CmdGetThemesReq, Array<GetThemesResponse>], cmd_enable_encryption: [CmdEnableEncryptionReq, null], cmd_reveal_workspace_key: [CmdRevealWorkspaceKeyReq, string], cmd_set_workspace_key: [CmdSetWorkspaceKeyReq, null], cmd_disable_encryption: [CmdDisableEncryptionReq, null], cmd_default_headers: [CmdDefaultHeadersReq, Array<HttpRequestHeader>], models_upsert: [ModelsUpsertReq, string], models_delete: [ModelsDeleteReq, string], models_duplicate: [ModelsDuplicateReq, string], models_websocket_events: [ModelsWebsocketEventsReq, Array<WebsocketEvent>], models_grpc_events: [ModelsGrpcEventsReq, Array<GrpcEvent>], models_get_settings: [ModelsGetSettingsReq, Settings], models_get_graphql_introspection: [ModelsGetGraphqlIntrospectionReq, GraphQlIntrospection | null], models_upsert_graphql_introspection: [ModelsUpsertGraphqlIntrospectionReq, GraphQlIntrospection], models_workspace_models: [ModelsWorkspaceModelsReq, string], cmd_git_checkout: [CmdGitCheckoutReq, string], cmd_git_branch: [CmdGitBranchReq, null], cmd_git_delete_branch: [CmdGitDeleteBranchReq, BranchDeleteResult], cmd_git_delete_remote_branch: [CmdGitDeleteRemoteBranchReq, null], cmd_git_merge_branch: [CmdGitMergeBranchReq, null], cmd_git_rename_branch: [CmdGitRenameBranchReq, null], cmd_git_status: [CmdGitStatusReq, GitStatLine truncated
|
||||
|
||||
export type WatchResult = { unlistenEvent: string, };
|
||||
+6
-2
@@ -1,5 +1,9 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type PluginMetadata = { version: string, name: string, displayName: string, description: string | null, homepageUrl: string | null, repositoryUrl: string | null, };
|
||||
export type PluginMetadata = { version: string, name: string, displayName: string, description: string | null, homepageUrl: string | null, repositoryUrl: string | null,
|
||||
/**
|
||||
* Why the plugin should no longer be used, from `deprecated` in its package.json
|
||||
*/
|
||||
deprecated: string | null, };
|
||||
|
||||
export type PluginVersion = { id: string, version: string, url: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, };
|
||||
export type PluginVersion = { id: string, version: string, url: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, deprecated: string | null, };
|
||||
@@ -97,6 +97,35 @@ pub struct CmdSyncWatchReq {
|
||||
#[ts(export, export_to = "gen_rpc.ts")]
|
||||
pub struct CmdMetadataReq {}
|
||||
|
||||
/// A coding agent the Agents settings pane can set up.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to = "gen_rpc.ts")]
|
||||
pub enum AgentClient {
|
||||
ClaudeCode,
|
||||
Codex,
|
||||
Cursor,
|
||||
Vscode,
|
||||
Other,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "gen_rpc.ts")]
|
||||
pub struct CmdAgentSetupStatusReq {
|
||||
pub agent: AgentClient,
|
||||
}
|
||||
|
||||
/// Which setup steps an agent already has done on this machine. `None` means
|
||||
/// the pane cannot tell for that agent.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "gen_rpc.ts")]
|
||||
pub struct AgentSetupStatus {
|
||||
pub mcp_server: Option<bool>,
|
||||
pub skill: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "gen_rpc.ts")]
|
||||
@@ -928,6 +957,7 @@ macro_rules! with_commands {
|
||||
($callback:ident) => {
|
||||
$callback! {
|
||||
cmd_metadata(CmdMetadataReq) -> AppMetaData,
|
||||
cmd_agent_setup_status(CmdAgentSetupStatusReq) -> AgentSetupStatus,
|
||||
cmd_template_tokens_to_string(CmdTemplateTokensToStringReq) -> String,
|
||||
cmd_render_template(CmdRenderTemplateReq) -> String,
|
||||
cmd_send_feedback(CmdSendFeedbackReq) -> (),
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
//! Which of the Agents pane's setup steps are already done on this machine.
|
||||
//!
|
||||
//! Detection reads the files the agents keep their MCP servers in and the
|
||||
//! skills directory `yaak agent install` writes to. A missing or unparsable
|
||||
//! file is "not detected", never an error: the pane shows a done mark when it
|
||||
//! can, and the command when it cannot.
|
||||
|
||||
use serde_json::Value;
|
||||
use std::path::{Path, PathBuf};
|
||||
use yaak_rpc_schema::{AgentClient, AgentSetupStatus};
|
||||
|
||||
const SKILL_NAME: &str = "use-yaak";
|
||||
const SERVER_NAME: &str = "yaak";
|
||||
|
||||
pub fn agent_setup_status(home: &Path, agent: AgentClient) -> AgentSetupStatus {
|
||||
AgentSetupStatus {
|
||||
mcp_server: mcp_server_added(home, agent),
|
||||
skill: skill_installed(home, agent),
|
||||
}
|
||||
}
|
||||
|
||||
fn skill_installed(home: &Path, agent: AgentClient) -> Option<bool> {
|
||||
let skills_dir = match agent {
|
||||
AgentClient::ClaudeCode => home.join(".claude").join("skills"),
|
||||
AgentClient::Codex => home.join(".codex").join("skills"),
|
||||
AgentClient::Cursor => home.join(".cursor").join("skills"),
|
||||
AgentClient::Vscode | AgentClient::Other => home.join(".agents").join("skills"),
|
||||
};
|
||||
Some(skills_dir.join(SKILL_NAME).is_dir())
|
||||
}
|
||||
|
||||
fn mcp_server_added(home: &Path, agent: AgentClient) -> Option<bool> {
|
||||
match agent {
|
||||
AgentClient::ClaudeCode => Some(claude_code_has_server(&home.join(".claude.json"))),
|
||||
AgentClient::Codex => Some(codex_has_server(&home.join(".codex").join("config.toml"))),
|
||||
AgentClient::Cursor => {
|
||||
Some(json_has_server(&home.join(".cursor").join("mcp.json"), "mcpServers"))
|
||||
}
|
||||
AgentClient::Vscode => Some(json_has_server(&vscode_user_mcp_json(home), "servers")),
|
||||
AgentClient::Other => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn vscode_user_mcp_json(home: &Path) -> PathBuf {
|
||||
let user_dir = if cfg!(target_os = "macos") {
|
||||
home.join("Library").join("Application Support").join("Code").join("User")
|
||||
} else if cfg!(target_os = "windows") {
|
||||
std::env::var_os("APPDATA")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| home.join("AppData").join("Roaming"))
|
||||
.join("Code")
|
||||
.join("User")
|
||||
} else {
|
||||
home.join(".config").join("Code").join("User")
|
||||
};
|
||||
user_dir.join("mcp.json")
|
||||
}
|
||||
|
||||
fn read_json(path: &Path) -> Option<Value> {
|
||||
let text = std::fs::read_to_string(path).ok()?;
|
||||
serde_json::from_str(&text).ok()
|
||||
}
|
||||
|
||||
/// Only the CLI's own entry counts. An entry named `yaak` that points at a
|
||||
/// URL is the deprecated plugin's server and still needs replacing.
|
||||
fn has_server(servers: Option<&Value>) -> bool {
|
||||
servers.and_then(|s| s.get(SERVER_NAME)).is_some_and(is_cli_server)
|
||||
}
|
||||
|
||||
fn is_cli_server(entry: &Value) -> bool {
|
||||
let command = entry.get("command").and_then(Value::as_str);
|
||||
let args: Vec<&str> = entry
|
||||
.get("args")
|
||||
.and_then(Value::as_array)
|
||||
.map(|a| a.iter().filter_map(Value::as_str).collect())
|
||||
.unwrap_or_default();
|
||||
is_cli_launch(command, &args)
|
||||
}
|
||||
|
||||
/// `yaak mcp`, or `npx -y @yaakapp/cli mcp`, which runs the same binary.
|
||||
fn is_cli_launch(command: Option<&str>, args: &[&str]) -> bool {
|
||||
let has_mcp = args.contains(&"mcp");
|
||||
let via_npx = command_stem(command) == Some("npx")
|
||||
&& args.iter().any(|a| a.trim_start_matches("@yaakapp/cli").len() < a.len());
|
||||
has_mcp && (command_stem(command) == Some("yaak") || via_npx)
|
||||
}
|
||||
|
||||
fn command_stem(command: Option<&str>) -> Option<&str> {
|
||||
command.and_then(|c| Path::new(c).file_stem().and_then(|s| s.to_str()))
|
||||
}
|
||||
|
||||
fn json_has_server(path: &Path, key: &str) -> bool {
|
||||
read_json(path).is_some_and(|root| has_server(root.get(key)))
|
||||
}
|
||||
|
||||
/// `claude mcp add` writes to the top level with `-s user` and under the
|
||||
/// current project's entry without it, so both count.
|
||||
fn claude_code_has_server(path: &Path) -> bool {
|
||||
let Some(root) = read_json(path) else {
|
||||
return false;
|
||||
};
|
||||
if has_server(root.get("mcpServers")) {
|
||||
return true;
|
||||
}
|
||||
root.get("projects")
|
||||
.and_then(|p| p.as_object())
|
||||
.is_some_and(|projects| projects.values().any(|p| has_server(p.get("mcpServers"))))
|
||||
}
|
||||
|
||||
/// A `[mcp_servers.yaak]` table, key bare or quoted, whose `command` is yaak
|
||||
/// and whose `args` include mcp. The file is scanned line by line, not parsed.
|
||||
fn codex_has_server(path: &Path) -> bool {
|
||||
let Ok(text) = std::fs::read_to_string(path) else {
|
||||
return false;
|
||||
};
|
||||
let mut in_table = false;
|
||||
let mut command = None;
|
||||
let mut args = Vec::new();
|
||||
let mut in_args = false;
|
||||
for line in text.lines().map(str::trim) {
|
||||
if line.starts_with('[') {
|
||||
in_table = is_codex_server_header(line);
|
||||
in_args = false;
|
||||
} else if in_table {
|
||||
let rest = if in_args {
|
||||
Some(line)
|
||||
} else if let Some((key, value)) = line.split_once('=') {
|
||||
match key.trim() {
|
||||
"command" => {
|
||||
command = Some(value.trim().trim_matches(QUOTES).to_string());
|
||||
None
|
||||
}
|
||||
"args" => Some(value),
|
||||
_other => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some(rest) = rest {
|
||||
args.extend(
|
||||
rest.split(',')
|
||||
.map(|a| a.trim().trim_matches(QUOTES_OR_BRACKETS))
|
||||
.filter(|a| !a.is_empty())
|
||||
.map(str::to_string),
|
||||
);
|
||||
in_args = !rest.contains(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
let args: Vec<&str> = args.iter().map(String::as_str).collect();
|
||||
is_cli_launch(command.as_deref(), &args)
|
||||
}
|
||||
|
||||
const QUOTES: [char; 2] = ['"', '\''];
|
||||
const QUOTES_OR_BRACKETS: [char; 4] = ['"', '\'', '[', ']'];
|
||||
|
||||
fn is_codex_server_header(line: &str) -> bool {
|
||||
let Some(rest) = line.strip_prefix('[') else {
|
||||
return false;
|
||||
};
|
||||
let Some(inner) = rest.split(']').next() else {
|
||||
return false;
|
||||
};
|
||||
let mut parts = inner.split('.').map(|p| p.trim().trim_matches(|c| c == '"' || c == '\''));
|
||||
parts.next() == Some("mcp_servers") && parts.next() == Some(SERVER_NAME)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
|
||||
fn write(path: &Path, contents: &str) {
|
||||
fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
fs::write(path, contents).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_installed() {
|
||||
let home = tempfile::tempdir().unwrap();
|
||||
for agent in [
|
||||
AgentClient::ClaudeCode,
|
||||
AgentClient::Codex,
|
||||
AgentClient::Cursor,
|
||||
AgentClient::Vscode,
|
||||
] {
|
||||
let status = agent_setup_status(home.path(), agent);
|
||||
assert_eq!(status.mcp_server, Some(false), "{agent:?}");
|
||||
assert_eq!(status.skill, Some(false), "{agent:?}");
|
||||
}
|
||||
let other = agent_setup_status(home.path(), AgentClient::Other);
|
||||
assert_eq!(other.mcp_server, None);
|
||||
assert_eq!(other.skill, Some(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skill_directories_per_agent() {
|
||||
let home = tempfile::tempdir().unwrap();
|
||||
fs::create_dir_all(home.path().join(".claude/skills/use-yaak")).unwrap();
|
||||
fs::create_dir_all(home.path().join(".agents/skills/use-yaak")).unwrap();
|
||||
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::ClaudeCode).skill, Some(true));
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).skill, Some(false));
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Cursor).skill, Some(false));
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Vscode).skill, Some(true));
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Other).skill, Some(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn claude_code_top_level_or_project_scope() {
|
||||
let home = tempfile::tempdir().unwrap();
|
||||
let path = home.path().join(".claude.json");
|
||||
|
||||
write(&path, r#"{"mcpServers":{"yaak":{"command":"yaak","args":["mcp"]}}}"#);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::ClaudeCode).mcp_server, Some(true));
|
||||
|
||||
write(
|
||||
&path,
|
||||
r#"{"projects":{"/Users/me/app":{"mcpServers":{"yaak":{"command":"/usr/local/bin/yaak","args":["mcp"]}}}}}"#,
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::ClaudeCode).mcp_server, Some(true));
|
||||
|
||||
write(
|
||||
&path,
|
||||
r#"{"mcpServers":{"yaak":{"type":"http","url":"http://127.0.0.1:64343/mcp"}}}"#,
|
||||
);
|
||||
assert_eq!(
|
||||
agent_setup_status(home.path(), AgentClient::ClaudeCode).mcp_server,
|
||||
Some(false)
|
||||
);
|
||||
|
||||
write(&path, r#"{"mcpServers":{"other":{}},"projects":{"/x":{"mcpServers":{}}}}"#);
|
||||
assert_eq!(
|
||||
agent_setup_status(home.path(), AgentClient::ClaudeCode).mcp_server,
|
||||
Some(false)
|
||||
);
|
||||
|
||||
write(&path, "{ not json");
|
||||
assert_eq!(
|
||||
agent_setup_status(home.path(), AgentClient::ClaudeCode).mcp_server,
|
||||
Some(false)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_table_header() {
|
||||
let home = tempfile::tempdir().unwrap();
|
||||
let path = home.path().join(".codex/config.toml");
|
||||
|
||||
write(
|
||||
&path,
|
||||
"model = \"o3\"\n\n[mcp_servers.yaak]\ncommand = \"yaak\"\nargs = [\"mcp\"]\n",
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).mcp_server, Some(true));
|
||||
|
||||
write(&path, " [ mcp_servers . \"yaak\" ]\ncommand = 'yaak'\nargs = ['mcp']\n[other]\n");
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).mcp_server, Some(true));
|
||||
|
||||
write(&path, "[mcp_servers.yaak]\nurl = \"http://127.0.0.1:64343/mcp\"\n");
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).mcp_server, Some(false));
|
||||
|
||||
write(&path, "[mcp_servers.yaak]\ncommand = \"yaak\"\nargs = [\n \"mcp\",\n]\n");
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).mcp_server, Some(true));
|
||||
|
||||
write(&path, "[mcp_servers.yaak.env]\nFOO = \"bar\"\n");
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).mcp_server, Some(false));
|
||||
|
||||
write(
|
||||
&path,
|
||||
"[mcp_servers.yaak]\n[mcp_servers.other]\ncommand = \"yaak\"\nargs = [\"mcp\"]\n",
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).mcp_server, Some(false));
|
||||
|
||||
write(&path, "[mcp_servers.yaakish]\ncommand = \"x\"\n[mcp_servers]\n");
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Codex).mcp_server, Some(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cursor_and_vscode_json() {
|
||||
let home = tempfile::tempdir().unwrap();
|
||||
|
||||
write(
|
||||
&home.path().join(".cursor/mcp.json"),
|
||||
r#"{"mcpServers":{"yaak":{"command":"yaak","args":["mcp"]}}}"#,
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Cursor).mcp_server, Some(true));
|
||||
|
||||
write(
|
||||
&home.path().join(".cursor/mcp.json"),
|
||||
r#"{"mcpServers":{"yaak":{"url":"http://127.0.0.1:64343/mcp"}}}"#,
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Cursor).mcp_server, Some(false));
|
||||
|
||||
write(
|
||||
&home.path().join(".cursor/mcp.json"),
|
||||
r#"{"mcpServers":{"yaak":{"command":"npx","args":["-y","@yaakapp/cli","mcp"]}}}"#,
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Cursor).mcp_server, Some(true));
|
||||
|
||||
write(
|
||||
&home.path().join(".cursor/mcp.json"),
|
||||
r#"{"mcpServers":{"yaak":{"command":"npx","args":["-y","mcp-remote","http://127.0.0.1:64343/mcp"]}}}"#,
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Cursor).mcp_server, Some(false));
|
||||
|
||||
write(&home.path().join(".cursor/mcp.json"), r#"{"servers":{"yaak":{}}}"#);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Cursor).mcp_server, Some(false));
|
||||
|
||||
if !cfg!(target_os = "windows") {
|
||||
write(
|
||||
&vscode_user_mcp_json(home.path()),
|
||||
r#"{"servers":{"yaak":{"type":"stdio","command":"yaak","args":["mcp"]}}}"#,
|
||||
);
|
||||
assert_eq!(agent_setup_status(home.path(), AgentClient::Vscode).mcp_server, Some(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
//! can serve (native windows, the updater, dialogs) or that still lean on it.
|
||||
|
||||
pub mod actions;
|
||||
pub mod agents;
|
||||
pub mod auth;
|
||||
pub mod data;
|
||||
pub mod encryption;
|
||||
|
||||
@@ -37,6 +37,7 @@ fn fallback_plugin_metadata(directory: &str) -> PluginMetadata {
|
||||
description: Some(format!("Plugin metadata could not be loaded from {directory}")),
|
||||
homepage_url: None,
|
||||
repository_url: None,
|
||||
deprecated: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Yaak's MCP server: the tools, written once against [`McpHost`], and the
|
||||
//! transports the app (streamable HTTP) and the CLI (stdio) serve them on.
|
||||
//! transports the CLI serves them on: stdio by default, streamable HTTP with
|
||||
//! `yaak mcp --http`.
|
||||
|
||||
pub mod http;
|
||||
mod params;
|
||||
|
||||
+6
-2
@@ -1,5 +1,9 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type PluginMetadata = { version: string, name: string, displayName: string, description: string | null, homepageUrl: string | null, repositoryUrl: string | null, };
|
||||
export type PluginMetadata = { version: string, name: string, displayName: string, description: string | null, homepageUrl: string | null, repositoryUrl: string | null,
|
||||
/**
|
||||
* Why the plugin should no longer be used, from `deprecated` in its package.json
|
||||
*/
|
||||
deprecated: string | null, };
|
||||
|
||||
export type PluginVersion = { id: string, version: string, url: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, };
|
||||
export type PluginVersion = { id: string, version: string, url: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, deprecated: string | null, };
|
||||
@@ -109,7 +109,10 @@ pub struct PluginVersion {
|
||||
pub repository_url: Option<String>,
|
||||
pub checksum: String,
|
||||
pub readme: Option<String>,
|
||||
#[serde(default)]
|
||||
pub yanked: bool,
|
||||
#[serde(default)]
|
||||
pub deprecated: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS, PartialEq)]
|
||||
|
||||
@@ -14,6 +14,8 @@ pub struct PluginMetadata {
|
||||
pub description: Option<String>,
|
||||
pub homepage_url: Option<String>,
|
||||
pub repository_url: Option<String>,
|
||||
/// Why the plugin should no longer be used, from `deprecated` in its package.json
|
||||
pub deprecated: Option<String>,
|
||||
}
|
||||
|
||||
pub fn get_plugin_meta(plugin_dir: &Path) -> Result<PluginMetadata> {
|
||||
@@ -37,6 +39,7 @@ pub fn get_plugin_meta(plugin_dir: &Path) -> Result<PluginMetadata> {
|
||||
name: package_json.name,
|
||||
display_name,
|
||||
homepage_url: package_json.homepage,
|
||||
deprecated: package_json.deprecated,
|
||||
repository_url: match package_json.repository {
|
||||
None => None,
|
||||
Some(RepositoryField::Object { url }) => Some(url),
|
||||
@@ -54,6 +57,7 @@ struct PackageJson {
|
||||
pub repository: Option<RepositoryField>,
|
||||
pub homepage: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub deprecated: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
@@ -313,7 +313,7 @@ export interface PlatformCapabilities {
|
||||
systemFonts: boolean;
|
||||
/** Commercial licence activation. */
|
||||
license: boolean;
|
||||
/** Connecting local AI agents: the Yaak CLI on this machine and the app's own MCP server. */
|
||||
/** Connecting local AI agents through the Yaak CLI on this machine. */
|
||||
agents: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -398,6 +398,7 @@ export type Settings = {
|
||||
updateChannel: string;
|
||||
hideLicenseBadge: boolean;
|
||||
promptFeedback: boolean;
|
||||
mcpServerEnabled: boolean;
|
||||
autoupdate: boolean;
|
||||
autoDownloadUpdates: boolean;
|
||||
checkNotifications: boolean;
|
||||
|
||||
+6
-2
@@ -1,5 +1,9 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type PluginMetadata = { version: string, name: string, displayName: string, description: string | null, homepageUrl: string | null, repositoryUrl: string | null, };
|
||||
export type PluginMetadata = { version: string, name: string, displayName: string, description: string | null, homepageUrl: string | null, repositoryUrl: string | null,
|
||||
/**
|
||||
* Why the plugin should no longer be used, from `deprecated` in its package.json
|
||||
*/
|
||||
deprecated: string | null, };
|
||||
|
||||
export type PluginVersion = { id: string, version: string, url: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, };
|
||||
export type PluginVersion = { id: string, version: string, url: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, deprecated: string | null, };
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
Exposes Yaak's functionality via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/).
|
||||
|
||||
**Deprecated.** Yaak now has a built-in MCP server with the same tools. Uninstall this plugin,
|
||||
then turn the server on in Settings > Agents, or run `yaak mcp` from the Yaak CLI.
|
||||
**Deprecated.** The Yaak CLI serves the same tools with `yaak mcp`, with the app open or
|
||||
closed. Install the CLI (`npm install -g @yaakapp/cli`), point your agent at `yaak mcp`, then
|
||||
uninstall this plugin. Settings > Agents in Yaak has the command for each agent.
|
||||
|
||||
## Setup
|
||||
|
||||
@@ -13,14 +14,14 @@ Add this to your Claude Desktop config (`~/Library/Application Support/Claude/cl
|
||||
{
|
||||
"mcpServers": {
|
||||
"yaak": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "mcp-remote", "http://127.0.0.1:64343/mcp"]
|
||||
"command": "yaak",
|
||||
"args": ["mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Restart Claude Desktop and make sure Yaak is running.
|
||||
Restart Claude Desktop.
|
||||
|
||||
## Available Tools
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"name": "@yaak/mcp-server",
|
||||
"displayName": "MCP Server",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"description": "Expose Yaak functionality via Model Context Protocol",
|
||||
"deprecated": "Replaced by the built-in `yaak mcp` in the Yaak CLI. Install the CLI instead.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mountain-loop/yaak.git",
|
||||
|
||||
@@ -13,7 +13,7 @@ export const plugin: PluginDefinition = {
|
||||
setTimeout(async () => {
|
||||
void ctx.toast.show({
|
||||
message:
|
||||
"The MCP Server plugin is deprecated. Yaak now has a built-in MCP server: uninstall this plugin, then turn it on in Settings > Agents.",
|
||||
"The MCP Server plugin is deprecated. Install the Yaak CLI, point your agent at `yaak mcp`, then uninstall this plugin.",
|
||||
icon: "alert_triangle",
|
||||
color: "notice",
|
||||
timeout: 30000,
|
||||
|
||||
Reference in new issue
Block a user