refactor: remove dead useMcpRegistration hook, add design file

useMcpRegistration is fully replaced by useMcpStatus which combines
detection + registration. Added design placeholder for MCP status bar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-03-04 13:16:23 +01:00
parent 4dbcc7c298
commit 9d8cf4da29
3 changed files with 10 additions and 35 deletions

View File

@@ -0,0 +1 @@
{"children":[],"variables":{}}

View File

@@ -193,7 +193,11 @@ pub fn check_mcp_status() -> McpStatus {
}
// Verify the referenced index.js actually exists on disk
if let Some(index_js) = entry["args"].as_array().and_then(|a| a.first()).and_then(|v| v.as_str()) {
if let Some(index_js) = entry["args"]
.as_array()
.and_then(|a| a.first())
.and_then(|v| v.as_str())
{
if !Path::new(index_js).exists() {
return McpStatus::NotInstalled;
}
@@ -381,7 +385,10 @@ mod tests {
// On CI without Claude it might be NoClaudeCli. Either way it must not panic.
let status = check_mcp_status();
assert!(
matches!(status, McpStatus::Installed | McpStatus::NotInstalled | McpStatus::NoClaudeCli),
matches!(
status,
McpStatus::Installed | McpStatus::NotInstalled | McpStatus::NoClaudeCli
),
"unexpected status: {:?}",
status
);

View File

@@ -1,33 +0,0 @@
import { useEffect, useRef } from 'react'
import { invoke } from '@tauri-apps/api/core'
import { isTauri, mockInvoke } from '../mock-tauri'
function tauriCall<T>(command: string, args: Record<string, unknown>): Promise<T> {
return isTauri() ? invoke<T>(command, args) : mockInvoke<T>(command, args)
}
/**
* Registers Laputa as an MCP server in Claude Code and Cursor config files.
* Fires once per vault path (skips duplicates).
*/
export function useMcpRegistration(
vaultPath: string,
onToast: (msg: string) => void,
) {
const registeredRef = useRef<string | null>(null)
useEffect(() => {
if (registeredRef.current === vaultPath) return
registeredRef.current = vaultPath
tauriCall<string>('register_mcp_tools', { vaultPath })
.then((status) => {
if (status === 'registered') {
onToast('Laputa registered as MCP tool for Claude Code')
}
})
.catch(() => {
// Silently ignore — not critical for app operation
})
}, [vaultPath]) // eslint-disable-line react-hooks/exhaustive-deps -- onToast is stable via ref
}