mcp_kit/plugin/
registry.rs1use crate::error::{McpError, McpResult};
4use serde::{Deserialize, Serialize};
5use std::path::PathBuf;
6
7#[allow(dead_code)]
9pub struct PluginRegistry {
10 registry_url: String,
11 cache_dir: PathBuf,
12}
13
14impl PluginRegistry {
15 pub fn new(registry_url: String) -> Self {
17 let cache_dir = dirs::cache_dir()
18 .unwrap_or_else(|| PathBuf::from("."))
19 .join("mcp-kit")
20 .join("plugins");
21
22 Self {
23 registry_url,
24 cache_dir,
25 }
26 }
27
28 pub fn default_registry() -> Self {
30 Self::new("https://mcp-plugins.io".to_string())
31 }
32
33 pub async fn search(&self, query: &str) -> McpResult<Vec<PluginInfo>> {
35 let _ = query;
37 Err(McpError::internal(
38 "Registry search not yet implemented".to_string(),
39 ))
40 }
41
42 pub async fn install(&self, name: &str, version: Option<&str>) -> McpResult<PathBuf> {
44 let _ = (name, version);
46 Err(McpError::internal(
47 "Plugin installation not yet implemented".to_string(),
48 ))
49 }
50
51 pub async fn info(&self, name: &str) -> McpResult<PluginInfo> {
53 let _ = name;
55 Err(McpError::internal(
56 "Plugin info fetching not yet implemented".to_string(),
57 ))
58 }
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct PluginInfo {
64 pub name: String,
65 pub version: String,
66 pub description: String,
67 pub author: String,
68 pub downloads: u64,
69 pub repository: Option<String>,
70 pub license: Option<String>,
71}
72
73fn dirs_cache_dir() -> Option<PathBuf> {
75 #[cfg(target_os = "linux")]
76 {
77 std::env::var_os("XDG_CACHE_HOME")
78 .map(PathBuf::from)
79 .or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".cache")))
80 }
81
82 #[cfg(target_os = "macos")]
83 {
84 std::env::var_os("HOME").map(|h| PathBuf::from(h).join("Library/Caches"))
85 }
86
87 #[cfg(target_os = "windows")]
88 {
89 std::env::var_os("LOCALAPPDATA").map(PathBuf::from)
90 }
91
92 #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
93 {
94 None
95 }
96}
97
98mod dirs {
99 use super::*;
100 pub fn cache_dir() -> Option<PathBuf> {
101 dirs_cache_dir()
102 }
103}