phone-a-friend-mcp-server 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,8 @@ from phone_a_friend_mcp_server.server import serve
15
15
  @click.option("--model", help="Model to use (e.g., 'gpt-4', 'anthropic/claude-3.5-sonnet')")
16
16
  @click.option("--provider", help="Provider type ('openai', 'openrouter', 'anthropic', 'google')")
17
17
  @click.option("--base-url", help="Base URL for API")
18
- def main(verbose: int, api_key: str = None, model: str = None, provider: str = None, base_url: str = None) -> None:
18
+ @click.option("--temperature", type=float, help="Temperature for the model (0.0-2.0). Lower values = more deterministic, higher = more creative")
19
+ def main(verbose: int, api_key: str = None, model: str = None, provider: str = None, base_url: str = None, temperature: float = None) -> None:
19
20
  """MCP server for Phone-a-Friend AI consultation"""
20
21
  logging_level = logging.WARN
21
22
  if verbose == 1:
@@ -25,7 +26,6 @@ def main(verbose: int, api_key: str = None, model: str = None, provider: str = N
25
26
 
26
27
  logging.basicConfig(level=logging_level, stream=sys.stderr)
27
28
 
28
- # Read environment variables with proper precedence
29
29
  config_api_key = (
30
30
  api_key
31
31
  or os.environ.get("OPENROUTER_API_KEY")
@@ -37,15 +37,12 @@ def main(verbose: int, api_key: str = None, model: str = None, provider: str = N
37
37
  config_model = model or os.environ.get("PHONE_A_FRIEND_MODEL")
38
38
  config_provider = provider or os.environ.get("PHONE_A_FRIEND_PROVIDER")
39
39
  config_base_url = base_url or os.environ.get("PHONE_A_FRIEND_BASE_URL")
40
-
41
- # Initialize configuration
40
+ config_temperature = temperature
42
41
  try:
43
- config = PhoneAFriendConfig(api_key=config_api_key, model=config_model, provider=config_provider, base_url=config_base_url)
42
+ config = PhoneAFriendConfig(api_key=config_api_key, model=config_model, provider=config_provider, base_url=config_base_url, temperature=config_temperature)
44
43
  except ValueError as e:
45
44
  click.echo(f"Configuration error: {e}", err=True)
46
45
  sys.exit(1)
47
-
48
- # Start the server
49
46
  asyncio.run(serve(config))
50
47
 
51
48
 
@@ -1,28 +1,30 @@
1
+ import os
2
+
3
+
1
4
  class PhoneAFriendConfig:
2
5
  """Centralized configuration for Phone-a-Friend MCP server."""
3
6
 
4
- def __init__(self, api_key: str | None = None, model: str | None = None, base_url: str | None = None, provider: str | None = None) -> None:
7
+ def __init__(self, api_key: str | None = None, model: str | None = None, base_url: str | None = None, provider: str | None = None, temperature: float | None = None) -> None:
5
8
  """Initialize configuration with provided values.
6
9
 
7
10
  Args:
8
11
  api_key: API key for external AI services
9
12
  model: Model to use (e.g., 'gpt-4', 'anthropic/claude-3.5-sonnet')
10
13
  base_url: Custom base URL for API (optional, providers use defaults)
11
- provider: Provider type ('openai', 'openrouter', 'anthropic')
14
+ provider: Provider type ('openai', 'openrouter', 'anthropic', 'google')
15
+ temperature: Temperature value for the model (0.0-2.0), overrides defaults
12
16
  """
13
17
  self.api_key = api_key
14
18
  self.provider = provider or self._detect_provider()
15
19
  self.model = model or self._get_default_model()
16
- self.base_url = base_url # Only use if explicitly provided
20
+ self.base_url = base_url
21
+ self.temperature = self._validate_temperature(temperature)
17
22
 
18
- # Validate required configuration
19
23
  if not self.api_key:
20
24
  raise ValueError(f"Missing required API key for {self.provider}. Set {self._get_env_var_name()} environment variable or pass --api-key")
21
25
 
22
26
  def _detect_provider(self) -> str:
23
27
  """Detect provider based on available environment variables."""
24
- import os
25
-
26
28
  if os.environ.get("OPENROUTER_API_KEY"):
27
29
  return "openrouter"
28
30
  elif os.environ.get("ANTHROPIC_API_KEY"):
@@ -32,12 +34,11 @@ class PhoneAFriendConfig:
32
34
  elif os.environ.get("OPENAI_API_KEY"):
33
35
  return "openai"
34
36
  else:
35
- # Default to OpenAI
36
37
  return "openai"
37
38
 
38
39
  def _get_default_model(self) -> str:
39
40
  """Get default model based on provider."""
40
- models = {"openai": "o3", "openrouter": "anthropic/claude-4-opus", "anthropic": "claude-4-opus", "google": "gemini-2.5-pro-preview-05-06"}
41
+ models = {"openai": "o3", "openrouter": "anthropic/claude-4-opus", "anthropic": "claude-4-opus", "google": "gemini-2.5-pro-preview-06-05"}
41
42
  if self.provider not in models:
42
43
  raise ValueError(f"Unknown provider: {self.provider}. Supported providers: {list(models.keys())}")
43
44
  return models[self.provider]
@@ -46,3 +47,41 @@ class PhoneAFriendConfig:
46
47
  """Get environment variable name for the provider."""
47
48
  env_vars = {"openai": "OPENAI_API_KEY", "openrouter": "OPENROUTER_API_KEY", "anthropic": "ANTHROPIC_API_KEY", "google": "GOOGLE_API_KEY or GEMINI_API_KEY"}
48
49
  return env_vars.get(self.provider, "OPENAI_API_KEY")
50
+
51
+ def _validate_temperature(self, temperature: float | None) -> float | None:
52
+ """Validate temperature value or get from environment variable."""
53
+ temp_value = temperature
54
+ if temp_value is None:
55
+ env_temp = os.environ.get("PHONE_A_FRIEND_TEMPERATURE")
56
+ if env_temp is not None:
57
+ try:
58
+ temp_value = float(env_temp)
59
+ except ValueError:
60
+ raise ValueError(f"Invalid temperature value in PHONE_A_FRIEND_TEMPERATURE: {env_temp}")
61
+
62
+ if temp_value is None:
63
+ temp_value = self._get_default_temperature_for_model()
64
+
65
+ if temp_value is not None:
66
+ if not isinstance(temp_value, int | float):
67
+ raise ValueError(f"Temperature must be a number, got {type(temp_value).__name__}")
68
+ if not (0.0 <= temp_value <= 2.0):
69
+ raise ValueError(f"Temperature must be between 0.0 and 2.0, got {temp_value}")
70
+
71
+ return temp_value
72
+
73
+ def _get_default_temperature_for_model(self) -> float | None:
74
+ """Get default temperature for specific models that benefit from it."""
75
+ default_temperatures = {
76
+ "gemini-2.5-pro-preview-06-05": 0.0,
77
+ }
78
+
79
+ return default_temperatures.get(self.model)
80
+
81
+ def get_temperature(self) -> float | None:
82
+ """Get the temperature setting for the current model.
83
+
84
+ Returns:
85
+ Temperature value if set, None otherwise
86
+ """
87
+ return self.temperature
@@ -12,6 +12,22 @@ from phone_a_friend_mcp_server.tools.tool_manager import ToolManager
12
12
  logger = logging.getLogger(__name__)
13
13
 
14
14
 
15
+ def _format_tool_result(result: Any) -> str:
16
+ """Format tool result for display."""
17
+ if isinstance(result, dict):
18
+ formatted_result = ""
19
+ for key, value in result.items():
20
+ if isinstance(value, list):
21
+ formatted_result += f"{key.title()}:\n"
22
+ for item in value:
23
+ formatted_result += f" • {item}\n"
24
+ else:
25
+ formatted_result += f"{key.title()}: {value}\n"
26
+ return formatted_result.strip()
27
+ else:
28
+ return str(result)
29
+
30
+
15
31
  async def serve(config: PhoneAFriendConfig) -> None:
16
32
  """Start the Phone-a-Friend MCP server.
17
33
 
@@ -55,19 +71,8 @@ async def serve(config: PhoneAFriendConfig) -> None:
55
71
  logger.info(f"Calling tool: {name} with arguments: {arguments}")
56
72
  tool = tool_manager.get_tool(name)
57
73
  result = await tool.run(**arguments)
58
-
59
- if isinstance(result, dict):
60
- formatted_result = ""
61
- for key, value in result.items():
62
- if isinstance(value, list):
63
- formatted_result += f"{key.title()}:\n"
64
- for item in value:
65
- formatted_result += f" • {item}\n"
66
- else:
67
- formatted_result += f"{key.title()}: {value}\n"
68
- return [TextContent(type="text", text=formatted_result.strip())]
69
- else:
70
- return [TextContent(type="text", text=str(result))]
74
+ formatted_result = _format_tool_result(result)
75
+ return [TextContent(type="text", text=formatted_result)]
71
76
 
72
77
  except Exception as e:
73
78
  logger.error("Tool execution failed: %s", e)
@@ -23,7 +23,12 @@ class FaxAFriendTool(BaseTool):
23
23
 
24
24
  @property
25
25
  def description(self) -> str:
26
- return """🚨 **USE ONLY WHEN USER ASKS TO "fax a friend".**
26
+ return """🚨🚨🚨 **EXCLUSIVE USE ONLY** 🚨🚨🚨
27
+
28
+ **USE ONLY WHEN USER EXPLICITLY ASKS TO "fax a friend"**
29
+ **DO NOT use as fallback if phone_a_friend fails**
30
+ **DO NOT auto-switch between fax/phone tools**
31
+ **If this tool fails, ask user for guidance - do NOT try phone_a_friend**
27
32
 
28
33
  Purpose: pair-programming caliber *coding help* — reviews, debugging,
29
34
  refactors, design, migrations.
@@ -107,21 +112,34 @@ replacing <file="…"> blocks as needed. Commentary goes outside those tags."""
107
112
  'Bad: vague stuff like "make code better".'
108
113
  ),
109
114
  },
115
+ "output_directory": {
116
+ "type": "string",
117
+ "description": (
118
+ "Directory path where the fax_a_friend.md file will be created.\n"
119
+ "Recommended: Use the user's current working directory for convenience.\n"
120
+ "Must be a valid, writable directory path.\n"
121
+ "Examples: '/tmp', '~/Documents', './output', '/Users/username/Desktop'"
122
+ ),
123
+ },
110
124
  },
111
- "required": ["all_related_context", "task"],
125
+ "required": ["all_related_context", "task", "output_directory"],
112
126
  }
113
127
 
114
128
  async def run(self, **kwargs) -> dict[str, Any]:
115
129
  all_related_context = kwargs.get("all_related_context", "")
116
130
  any_additional_context = kwargs.get("any_additional_context", "")
117
131
  task = kwargs.get("task", "")
132
+ output_directory = kwargs.get("output_directory", "")
118
133
 
119
134
  # Create master prompt using the same logic as phone_a_friend
120
135
  master_prompt = self._create_master_prompt(all_related_context, any_additional_context, task)
121
136
 
122
137
  try:
123
- # Write to fax_a_friend.md in current working directory
124
- file_path = "fax_a_friend.md"
138
+ # Validate and prepare output directory
139
+ output_dir = self._prepare_output_directory(output_directory)
140
+
141
+ # Create full file path
142
+ file_path = os.path.join(output_dir, "fax_a_friend.md")
125
143
 
126
144
  async with aiofiles.open(file_path, "w", encoding="utf-8") as f:
127
145
  await f.write(master_prompt)
@@ -133,6 +151,7 @@ replacing <file="…"> blocks as needed. Commentary goes outside those tags."""
133
151
  "status": "success",
134
152
  "file_path": abs_path,
135
153
  "file_name": "fax_a_friend.md",
154
+ "output_directory": output_dir,
136
155
  "prompt_length": len(master_prompt),
137
156
  "context_length": len(all_related_context + any_additional_context),
138
157
  "task": task,
@@ -140,7 +159,7 @@ replacing <file="…"> blocks as needed. Commentary goes outside those tags."""
140
159
  }
141
160
 
142
161
  except Exception as e:
143
- return {"status": "failed", "error": str(e), "file_path": "fax_a_friend.md", "context_length": len(all_related_context + any_additional_context), "task": task}
162
+ return {"status": "failed", "error": str(e), "output_directory": output_directory, "context_length": len(all_related_context + any_additional_context), "task": task}
144
163
 
145
164
  def _create_master_prompt(self, all_related_context: str, any_additional_context: str, task: str) -> str:
146
165
  """Create a comprehensive prompt identical to PhoneAFriendTool's version."""
@@ -180,6 +199,27 @@ replacing <file="…"> blocks as needed. Commentary goes outside those tags."""
180
199
 
181
200
  return "\n".join(prompt_parts)
182
201
 
202
+ def _prepare_output_directory(self, output_directory: str) -> str:
203
+ """Validate and prepare the output directory."""
204
+ if not output_directory:
205
+ raise ValueError("output_directory parameter is required")
206
+
207
+ # Expand user path (~) and resolve relative paths
208
+ expanded_path = os.path.expanduser(output_directory)
209
+ resolved_path = os.path.abspath(expanded_path)
210
+
211
+ # Create directory if it doesn't exist
212
+ try:
213
+ os.makedirs(resolved_path, exist_ok=True)
214
+ except OSError as e:
215
+ raise ValueError(f"Cannot create directory '{resolved_path}': {e}")
216
+
217
+ # Check if directory is writable
218
+ if not os.access(resolved_path, os.W_OK):
219
+ raise ValueError(f"Directory '{resolved_path}' is not writable")
220
+
221
+ return resolved_path
222
+
183
223
  def _get_manual_workflow_instructions(self, file_path: str) -> str:
184
224
  """Generate clear instructions for the manual workflow."""
185
225
  return f"""
@@ -28,7 +28,12 @@ class PhoneAFriendTool(BaseTool):
28
28
 
29
29
  @property
30
30
  def description(self) -> str:
31
- return """🚨 **USE ONLY WHEN USER ASKS TO "phone a friend".**
31
+ return """🚨🚨🚨 **EXCLUSIVE USE ONLY** 🚨🚨🚨
32
+
33
+ **USE ONLY WHEN USER EXPLICITLY ASKS TO "phone a friend"**
34
+ **DO NOT use as fallback if fax_a_friend fails**
35
+ **DO NOT auto-switch between phone/fax tools**
36
+ **If this tool fails, ask user for guidance - do NOT try fax_a_friend**
32
37
 
33
38
  Purpose: pair-programming caliber *coding help* — reviews, debugging,
34
39
  refactors, design, migrations.
@@ -118,57 +123,57 @@ replacing <file="…"> blocks as needed. Commentary goes outside those tags."""
118
123
  any_additional_context = kwargs.get("any_additional_context", "")
119
124
  task = kwargs.get("task", "")
120
125
 
121
- # Create master prompt for external AI
122
126
  master_prompt = self._create_master_prompt(all_related_context, any_additional_context, task)
123
127
 
124
128
  try:
125
- # Create Pydantic-AI agent with appropriate provider
126
129
  agent = self._create_agent()
130
+ temperature = self.config.get_temperature()
127
131
 
128
- # Send to external AI
129
- result = await agent.run(master_prompt)
132
+ if temperature is not None:
133
+ result = await agent.run(master_prompt, model_settings={"temperature": temperature})
134
+ else:
135
+ result = await agent.run(master_prompt)
130
136
 
131
137
  return {
132
138
  "response": result.data,
133
139
  "status": "success",
134
140
  "provider": self.config.provider,
135
141
  "model": self.config.model,
142
+ "temperature": temperature,
136
143
  "context_length": len(all_related_context + any_additional_context),
137
144
  "task": task,
138
145
  }
139
146
 
140
147
  except Exception as e:
148
+ temperature = self.config.get_temperature()
141
149
  return {
142
150
  "error": str(e),
143
151
  "status": "failed",
144
152
  "provider": self.config.provider,
145
153
  "model": self.config.model,
154
+ "temperature": temperature,
146
155
  "context_length": len(all_related_context + any_additional_context),
147
156
  "task": task,
148
- "master_prompt": master_prompt, # Include for debugging
157
+ "master_prompt": master_prompt,
149
158
  }
150
159
 
151
160
  def _create_agent(self) -> Agent:
152
161
  """Create Pydantic-AI agent with appropriate provider."""
153
162
  if self.config.provider == "openrouter":
154
- # OpenRouter has its own dedicated provider
155
163
  provider_kwargs = {"api_key": self.config.api_key}
156
164
  if self.config.base_url:
157
165
  provider_kwargs["base_url"] = self.config.base_url
158
166
  provider = OpenRouterProvider(**provider_kwargs)
159
167
  model = OpenAIModel(self.config.model, provider=provider)
160
168
  elif self.config.provider == "anthropic":
161
- # Use Anthropic directly
162
169
  provider_kwargs = {"api_key": self.config.api_key}
163
170
  provider = AnthropicProvider(**provider_kwargs)
164
171
  model = AnthropicModel(self.config.model, provider=provider)
165
172
  elif self.config.provider == "google":
166
- # Use Google/Gemini directly
167
173
  provider_kwargs = {"api_key": self.config.api_key}
168
174
  provider = GoogleProvider(**provider_kwargs)
169
175
  model = GoogleModel(self.config.model, provider=provider)
170
176
  else:
171
- # Default to OpenAI
172
177
  provider_kwargs = {"api_key": self.config.api_key}
173
178
  if self.config.base_url:
174
179
  provider_kwargs["base_url"] = self.config.base_url
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.4
2
+ Name: phone-a-friend-mcp-server
3
+ Version: 0.1.2
4
+ Summary: MCP Server for Phone-a-Friend assistance
5
+ Project-URL: GitHub, https://github.com/abhishekbhakat/phone-a-friend-mcp-server
6
+ Project-URL: Issues, https://github.com/abhishekbhakat/phone-a-friend-mcp-server/issues
7
+ Author-email: Abhishek Bhakat <abhishek.bhakat@hotmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: aiofiles>=24.1.0
17
+ Requires-Dist: aiohttp>=3.12.7
18
+ Requires-Dist: click>=8.2.1
19
+ Requires-Dist: mcp>=1.9.2
20
+ Requires-Dist: pydantic-ai-slim[anthropic,google,openai]>=0.2.14
21
+ Requires-Dist: pydantic>=2.11.5
22
+ Requires-Dist: pyyaml>=6.0.0
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Phone-a-Friend MCP Server 🧠📞
26
+
27
+ An AI-to-AI consultation system that enables one AI to "phone a friend" (another AI) for critical thinking, long context reasoning, and complex problem solving via OpenRouter.
28
+
29
+ ## The Problem 🤔
30
+
31
+ Sometimes an AI encounters complex problems that require:
32
+ - **Deep critical thinking** beyond immediate capabilities
33
+ - **Long context reasoning** with extensive information
34
+ - **Multi-step analysis** that benefits from external perspective
35
+ - **Specialized expertise** from different AI models
36
+
37
+ ## The Solution �
38
+
39
+ Phone-a-Friend MCP Server creates a **two-step consultation process**:
40
+
41
+ 1. **Context + Reasoning**: Package all relevant context and send to external AI for deep analysis
42
+ 2. **Extract Actionable Insights**: Process the reasoning response into usable format for the primary AI
43
+
44
+ This enables AI systems to leverage other AI models as "consultants" for complex reasoning tasks.
45
+
46
+ ## Architecture 🏗️
47
+
48
+ ```
49
+ Primary AI → Phone-a-Friend MCP → OpenRouter → External AI (GPT-4, Claude, etc.) → Processed Response → Primary AI
50
+ ```
51
+
52
+ **Sequential Workflow:**
53
+ 1. `analyze_context` - Gather and structure all relevant context
54
+ 2. `get_critical_thinking` - Send context to external AI via OpenRouter for reasoning
55
+ 3. `extract_actionable_insights` - Process response into actionable format
56
+
57
+ ## When to Use 🎯
58
+
59
+ **Ideal for:**
60
+ - Complex multi-step problems requiring deep analysis
61
+ - Situations needing long context reasoning (>100k tokens)
62
+ - Cross-domain expertise consultation
63
+ - Critical decision-making with high stakes
64
+ - Problems requiring multiple perspectives
65
+
66
+ ## Installation 🚀
67
+
68
+ 1. Clone the repository:
69
+ ```bash
70
+ git clone https://github.com/abhishekbhakat/phone-a-friend-mcp-server.git
71
+ cd phone-a-friend-mcp-server
72
+ ```
73
+
74
+ 2. Install dependencies:
75
+ ```bash
76
+ uv pip install -e .
77
+ ```
78
+
79
+ 3. Configure API access (choose one method):
80
+
81
+ **Option A: Environment Variables**
82
+ ```bash
83
+ export OPENROUTER_API_KEY="your-openrouter-key"
84
+ # OR
85
+ export OPENAI_API_KEY="your-openai-key"
86
+ # OR
87
+ export ANTHROPIC_API_KEY="your-anthropic-key"
88
+ # OR
89
+ export GOOGLE_API_KEY="your-google-key"
90
+ ```
91
+
92
+ **Option B: CLI Arguments**
93
+ ```bash
94
+ phone-a-friend-mcp-server --api-key "your-api-key" --provider openai
95
+ ```
96
+
97
+ ## Usage 💡
98
+
99
+ ### Command Line Options
100
+ ```bash
101
+
102
+ # Custom base URL (if needed)
103
+ phone-a-friend-mcp-server --base-url "https://custom-api.example.com"
104
+
105
+ # Temperature control (0.0 = deterministic, 2.0 = very creative)
106
+ phone-a-friend-mcp-server --temperature 0.4
107
+
108
+ # Combined example
109
+ phone-a-friend-mcp-server --api-key "sk-..." --provider openai --model "o3" -v
110
+ ```
111
+
112
+ ### Environment Variables (Optional)
113
+ ```bash
114
+
115
+ # Optional model overrides
116
+ export PHONE_A_FRIEND_MODEL="your-preferred-model"
117
+ export PHONE_A_FRIEND_PROVIDER="your-preferred-provider"
118
+ export PHONE_A_FRIEND_BASE_URL="https://custom-api.example.com"
119
+
120
+ # Temperature control (0.0-2.0, where 0.0 = deterministic, 2.0 = very creative)
121
+ export PHONE_A_FRIEND_TEMPERATURE=0.4
122
+ ```
123
+
124
+ ## Model Selection 🤖
125
+
126
+ Default reasoning models to be selected:
127
+ - **OpenAI**: o3
128
+ - **Anthropic**: Claude 4 Opus
129
+ - **Google**: Gemini 2.5 Pro Preview 05-06 (automatically set temperature to 0.0)
130
+ - **OpenRouter**: For other models like Deepseek or Qwen
131
+
132
+ You can override the auto-selection by setting `PHONE_A_FRIEND_MODEL` environment variable or using the `--model` CLI option.
133
+
134
+ ## Available Tools 🛠️
135
+
136
+ ### phone_a_friend
137
+ 📞 Consult external AI for critical thinking and complex reasoning. Makes API calls to get responses.
138
+
139
+ ### fax_a_friend
140
+ 📠 Generate master prompt file for manual AI consultation. Creates file for copy-paste workflow.
141
+
142
+ **Parameters (both tools):**
143
+ - `all_related_context` (required): All context related to the problem
144
+ - `any_additional_context` (optional): Additional helpful context
145
+ - `task` (required): Specific task or question for the AI
146
+
147
+
148
+ ## Use Cases 🎯
149
+
150
+ 1. In-depth Reasoning for Vibe Coding
151
+ 2. For complex algorithms, data structures, or mathematical computations
152
+ 3. Frontend Development with React, Vue, CSS, or modern frontend frameworks
153
+
154
+ ## Claude Desktop Configuration 🖥️
155
+
156
+ To use Phone-a-Friend MCP server with Claude Desktop, add this configuration to your `claude_desktop_config.json` file:
157
+
158
+ ### Configuration File Location
159
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
160
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
161
+
162
+ ### Configuration
163
+
164
+ **Option 1: Using uv (Recommended)**
165
+ ```json
166
+ {
167
+ "mcpServers": {
168
+ "phone-a-friend": {
169
+ "command": "uvx",
170
+ "args": [
171
+ "--refresh",
172
+ "phone-a-friend-mcp-server",
173
+ ],
174
+ "env": {
175
+ "OPENROUTER_API_KEY": "your-openrouter-api-key",
176
+ "PHONE_A_FRIEND_MODEL": "anthropic/claude-4-opus",
177
+ "PHONE_A_FRIEND_TEMPERATURE": "0.4"
178
+ }
179
+ }
180
+ }
181
+ }
182
+ ```
183
+
184
+ ### Environment Variables in Configuration
185
+
186
+ You can configure different AI providers directly in the Claude Desktop config:
187
+
188
+ ```json
189
+ {
190
+ "mcpServers": {
191
+ "phone-a-friend": {
192
+ "command": "phone-a-friend-mcp-server",
193
+ "env": {
194
+ "OPENROUTER_API_KEY": "your-openrouter-api-key",
195
+ "PHONE_A_FRIEND_MODEL": "anthropic/claude-4-opus",
196
+ "PHONE_A_FRIEND_TEMPERATURE": "0.4"
197
+ }
198
+ }
199
+ }
200
+ }
201
+ ```
202
+
203
+ ## License 📄
204
+
205
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,15 @@
1
+ phone_a_friend_mcp_server/__init__.py,sha256=9sn_dPrIzLz4W7_Ww--o8aUxIhUI3YGNrxPa26pKShw,2025
2
+ phone_a_friend_mcp_server/__main__.py,sha256=A-8-jkY2FK2foabew5I-Wk2A54IwzWZcydlQKfiR-p4,51
3
+ phone_a_friend_mcp_server/config.py,sha256=McHqEzIVhSXpfmNLrCRlrFckRLzjxN5LESkqAXX6c4o,3953
4
+ phone_a_friend_mcp_server/server.py,sha256=z-O20j-j2oHFfFK8o0u9kn-MR8Q-Te0lRZOQfLkYUbM,3448
5
+ phone_a_friend_mcp_server/client/__init__.py,sha256=fsa8DXjz4rzYXmOUAdLdTpTwPSlZ3zobmBGXqnCEaWs,47
6
+ phone_a_friend_mcp_server/tools/__init__.py,sha256=jtuvmcStXzbaM8wuhOKC8M8mBqDjHr-ypZ2ct1Rgi7Q,46
7
+ phone_a_friend_mcp_server/tools/base_tools.py,sha256=DMjFq0E3TO9a9I7QY4wQ_B4-SntdXzSZzrYymFzSmVE,765
8
+ phone_a_friend_mcp_server/tools/fax_tool.py,sha256=qPKTDG1voXo_6MjgkMSDLN8AKYfal6sagK1l2BRPgCw,9399
9
+ phone_a_friend_mcp_server/tools/phone_tool.py,sha256=fPgYE8iRc9xFCQc07J5Zh4RPIbgYaiE6WygTEo6oUbs,8604
10
+ phone_a_friend_mcp_server/tools/tool_manager.py,sha256=VVtENC-n3D4GV6Cy3l9--30SJi06mJdyEiG7F_mfP7I,1474
11
+ phone_a_friend_mcp_server-0.1.2.dist-info/METADATA,sha256=sMh-qLXluzJMAR0YZcA-OaSajsxq4tAKODDNyG8Y_tc,6222
12
+ phone_a_friend_mcp_server-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ phone_a_friend_mcp_server-0.1.2.dist-info/entry_points.txt,sha256=c_08XI-vG07VmUT3mtzyuCQjaus5l1NBl4q00Q3jLug,86
14
+ phone_a_friend_mcp_server-0.1.2.dist-info/licenses/LICENSE,sha256=-8bInetillKZC0qZDT8RWYIOrph3HIU5cr5N4Pg7bBE,1065
15
+ phone_a_friend_mcp_server-0.1.2.dist-info/RECORD,,
@@ -1,320 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: phone-a-friend-mcp-server
3
- Version: 0.1.0
4
- Summary: MCP Server for Phone-a-Friend assistance
5
- Project-URL: GitHub, https://github.com/abhishekbhakat/phone-a-friend-mcp-server
6
- Project-URL: Issues, https://github.com/abhishekbhakat/phone-a-friend-mcp-server/issues
7
- Author-email: Abhishek Bhakat <abhishek.bhakat@hotmail.com>
8
- License-Expression: MIT
9
- License-File: LICENSE
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Operating System :: OS Independent
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Requires-Python: >=3.11
16
- Requires-Dist: aiofiles>=24.1.0
17
- Requires-Dist: aiohttp>=3.12.7
18
- Requires-Dist: click>=8.2.1
19
- Requires-Dist: mcp>=1.9.2
20
- Requires-Dist: pydantic-ai-slim[anthropic,google,openai]>=0.2.14
21
- Requires-Dist: pydantic>=2.11.5
22
- Requires-Dist: pyyaml>=6.0.0
23
- Provides-Extra: dev
24
- Requires-Dist: build>=1.2.2.post1; extra == 'dev'
25
- Requires-Dist: pre-commit>=4.2.0; extra == 'dev'
26
- Requires-Dist: pytest-asyncio>=0.26.0; extra == 'dev'
27
- Requires-Dist: pytest-mock>=3.14.1; extra == 'dev'
28
- Requires-Dist: pytest>=8.3.4; extra == 'dev'
29
- Requires-Dist: ruff>=0.11.12; extra == 'dev'
30
- Description-Content-Type: text/markdown
31
-
32
- # Phone-a-Friend MCP Server 🧠📞
33
-
34
- An AI-to-AI consultation system that enables one AI to "phone a friend" (another AI) for critical thinking, long context reasoning, and complex problem solving via OpenRouter.
35
-
36
- ## The Problem 🤔
37
-
38
- Sometimes an AI encounters complex problems that require:
39
- - **Deep critical thinking** beyond immediate capabilities
40
- - **Long context reasoning** with extensive information
41
- - **Multi-step analysis** that benefits from external perspective
42
- - **Specialized expertise** from different AI models
43
-
44
- ## The Solution �
45
-
46
- Phone-a-Friend MCP Server creates a **two-step consultation process**:
47
-
48
- 1. **Context + Reasoning**: Package all relevant context and send to external AI for deep analysis
49
- 2. **Extract Actionable Insights**: Process the reasoning response into usable format for the primary AI
50
-
51
- This enables AI systems to leverage other AI models as "consultants" for complex reasoning tasks.
52
-
53
- ## Architecture 🏗️
54
-
55
- ```
56
- Primary AI → Phone-a-Friend MCP → OpenRouter → External AI (GPT-4, Claude, etc.) → Processed Response → Primary AI
57
- ```
58
-
59
- **Sequential Workflow:**
60
- 1. `analyze_context` - Gather and structure all relevant context
61
- 2. `get_critical_thinking` - Send context to external AI via OpenRouter for reasoning
62
- 3. `extract_actionable_insights` - Process response into actionable format
63
-
64
- ## When to Use 🎯
65
-
66
- **Ideal for:**
67
- - Complex multi-step problems requiring deep analysis
68
- - Situations needing long context reasoning (>100k tokens)
69
- - Cross-domain expertise consultation
70
- - Critical decision-making with high stakes
71
- - Problems requiring multiple perspectives
72
-
73
- **Not needed for:**
74
- - Simple factual questions
75
- - Basic reasoning tasks
76
- - Quick responses
77
- - Well-defined procedural tasks
78
-
79
- ## Installation 🚀
80
-
81
- 1. Clone the repository:
82
- ```bash
83
- git clone https://github.com/abhishekbhakat/phone-a-friend-mcp-server.git
84
- cd phone-a-friend-mcp-server
85
- ```
86
-
87
- 2. Install dependencies:
88
- ```bash
89
- uv pip install -e .
90
- ```
91
-
92
- 3. Configure your preferred AI provider:
93
-
94
- **OpenRouter (recommended - access to multiple models):**
95
- ```bash
96
- export OPENROUTER_API_KEY="your-openrouter-key"
97
- # Model will auto-select based on provider
98
- ```
99
-
100
- **OpenAI:**
101
- ```bash
102
- export OPENAI_API_KEY="your-openai-key"
103
- # Uses latest available model by default
104
- ```
105
-
106
- **Anthropic:**
107
- ```bash
108
- export ANTHROPIC_API_KEY="your-anthropic-key"
109
- # Uses latest available model by default
110
- ```
111
-
112
- **Google/Gemini:**
113
- ```bash
114
- export GOOGLE_API_KEY="your-google-key" # or GEMINI_API_KEY
115
- # Uses latest available model by default
116
- ```
117
-
118
- ## Usage 💡
119
-
120
- ### Command Line
121
- ```bash
122
- # Start the server
123
- phone-a-friend-mcp-server
124
-
125
- # With verbose logging
126
- phone-a-friend-mcp-server -v
127
-
128
- # With specific provider (uses optimal model automatically)
129
- phone-a-friend-mcp-server --provider anthropic
130
- phone-a-friend-mcp-server --provider google
131
-
132
- # Override with custom model if needed
133
- phone-a-friend-mcp-server --provider anthropic --model "your-preferred-model"
134
- ```
135
-
136
- ### Environment Variables
137
- ```bash
138
- # Auto-detects provider based on available API keys
139
- export OPENROUTER_API_KEY="your-openrouter-key" # Preferred
140
- export OPENAI_API_KEY="your-openai-key" # Default fallback
141
- export ANTHROPIC_API_KEY="your-anthropic-key" # Direct Anthropic
142
- export GOOGLE_API_KEY="your-google-key" # Google/Gemini
143
-
144
- # Optional overrides (only if you want to override auto-selection)
145
- export PHONE_A_FRIEND_MODEL="your-preferred-model"
146
- export PHONE_A_FRIEND_PROVIDER="your-preferred-provider"
147
- ```
148
-
149
- ## Model Selection 🤖
150
-
151
- The system automatically selects the most capable model for each provider:
152
- - **OpenAI**: Latest reasoning model
153
- - **Anthropic**: Latest Claude model
154
- - **Google**: Latest Gemini Pro model
155
- - **OpenRouter**: Access to latest models from all providers
156
-
157
- You can override the auto-selection by setting `PHONE_A_FRIEND_MODEL` environment variable or using the `--model` CLI option.
158
-
159
- ## Available Tools 🛠️
160
-
161
- ### phone_a_friend
162
- Consult an external AI for critical thinking and complex reasoning via OpenRouter.
163
-
164
- **IMPORTANT:** The external AI is very smart but has NO MEMORY of previous conversations.
165
- The quality of the response depends ENTIRELY on the quality and completeness of the context you provide.
166
-
167
- **Parameters:**
168
- - `all_related_context` (required): ALL context directly related to the problem. Include:
169
- - Background information and history
170
- - Previous attempts and their outcomes
171
- - Stakeholders and their perspectives
172
- - Constraints, requirements, and limitations
173
- - Current situation and circumstances
174
- - Any relevant data, metrics, or examples
175
- - Timeline and deadlines
176
- - Success criteria and goals
177
-
178
- - `any_additional_context` (optional): ANY additional context that might be helpful. Include:
179
- - Relevant documentation, specifications, or guidelines
180
- - Industry standards or best practices
181
- - Similar cases or precedents
182
- - Technical details or domain knowledge
183
- - Regulatory or compliance requirements
184
- - Tools, resources, or technologies available
185
- - Budget or resource constraints
186
- - Organizational context or culture
187
-
188
- - `task` (required): The specific task or question for the external AI. Be clear about:
189
- - What exactly you need help with
190
- - What type of analysis or reasoning you want
191
- - What format you prefer for the response
192
- - What decisions need to be made
193
- - What problems need to be solved
194
-
195
- **Example Usage:**
196
- ```
197
- all_related_context: "We're a SaaS startup with 50 employees. Our customer churn rate increased from 5% to 12% over the last quarter. We recently changed our pricing model and added new features. Customer support tickets increased 40%. Our main competitors are offering similar features at lower prices."
198
-
199
- any_additional_context: "Industry benchmark for SaaS churn is 6-8%. Our pricing increased by 30%. New features include AI analytics and advanced reporting. Customer feedback mentions complexity and cost concerns."
200
-
201
- task: "Analyze the churn increase and provide a comprehensive action plan to reduce it back to 5% within 6 months. Include specific strategies, timeline, and success metrics."
202
- ```
203
-
204
- The system will automatically route this to the most capable AI model available based on your configured provider.
205
-
206
- ## Claude Desktop Configuration 🖥️
207
-
208
- To use Phone-a-Friend MCP server with Claude Desktop, add this configuration to your `claude_desktop_config.json` file:
209
-
210
- ### Configuration File Location
211
- - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
212
- - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
213
-
214
- ### Configuration
215
-
216
- **Option 1: Using uv (Recommended)**
217
- ```json
218
- {
219
- "mcpServers": {
220
- "phone-a-friend": {
221
- "command": "uvx",
222
- "args": [
223
- "run",
224
- "--refresh",
225
- "phone-a-friend-mcp-server",
226
- ],
227
- "env": {
228
- "OPENROUTER_API_KEY": "your-openrouter-api-key",
229
- "PHONE_A_FRIEND_MODEL": "anthropic/claude-4-opus"
230
- }
231
- }
232
- }
233
- }
234
- ```
235
-
236
- ### Environment Variables in Configuration
237
-
238
- You can configure different AI providers directly in the Claude Desktop config:
239
-
240
- ```json
241
- {
242
- "mcpServers": {
243
- "phone-a-friend": {
244
- "command": "phone-a-friend-mcp-server",
245
- "env": {
246
- "OPENROUTER_API_KEY": "your-openrouter-api-key",
247
- "PHONE_A_FRIEND_MODEL": "anthropic/claude-4-opus"
248
- }
249
- }
250
- }
251
- }
252
- ```
253
-
254
- **Alternative Providers:**
255
- ```json
256
- {
257
- "mcpServers": {
258
- "phone-a-friend-openai": {
259
- "command": "phone-a-friend-mcp-server",
260
- "env": {
261
- "OPENAI_API_KEY": "your-openai-api-key"
262
- }
263
- },
264
- "phone-a-friend-anthropic": {
265
- "command": "phone-a-friend-mcp-server",
266
- "env": {
267
- "ANTHROPIC_API_KEY": "your-anthropic-api-key"
268
- }
269
- },
270
- "phone-a-friend-google": {
271
- "command": "phone-a-friend-mcp-server",
272
- "env": {
273
- "GOOGLE_API_KEY": "your-google-api-key"
274
- }
275
- }
276
- }
277
- }
278
- ```
279
-
280
- ### Setup Steps
281
-
282
- 1. **Install Phone-a-Friend MCP Server** (see Installation section above)
283
- 2. **Open Claude Desktop Settings** → Developer → Edit Config
284
- 3. **Add the configuration** (choose one of the options above)
285
- 4. **Replace paths and API keys** with your actual values
286
- 5. **Restart Claude Desktop**
287
- 6. **Look for the 🔨 hammer icon** in the input box to confirm the server is connected
288
-
289
- ### Troubleshooting
290
-
291
- If the server doesn't appear in Claude Desktop:
292
-
293
- 1. **Check logs**:
294
- - macOS: `~/Library/Logs/Claude/mcp*.log`
295
- - Windows: `%APPDATA%\Claude\logs\mcp*.log`
296
-
297
- 2. **Verify paths** are absolute and correct
298
- 3. **Test manually** in terminal:
299
- ```bash
300
- phone-a-friend-mcp-server -v
301
- ```
302
- 4. **Restart Claude Desktop** completely
303
- 5. **Check API keys** are valid and have sufficient credits
304
-
305
- ## Development 🔧
306
-
307
- ### Running Tests
308
- ```bash
309
- pytest
310
- ```
311
-
312
- ### Code Formatting
313
- ```bash
314
- ruff format .
315
- ruff check .
316
- ```
317
-
318
- ## License 📄
319
-
320
- MIT License - see LICENSE file for details.
@@ -1,15 +0,0 @@
1
- phone_a_friend_mcp_server/__init__.py,sha256=RaayGu6L95bFNEioVLZwFifnKMl9-yhUU7glBInuqXA,1895
2
- phone_a_friend_mcp_server/__main__.py,sha256=A-8-jkY2FK2foabew5I-Wk2A54IwzWZcydlQKfiR-p4,51
3
- phone_a_friend_mcp_server/config.py,sha256=Wfs68Zw7xXhAQ-77z3gblqsnmqO5bed-f2ggJkvgzUM,2356
4
- phone_a_friend_mcp_server/server.py,sha256=ppx8QxQvJihcOzJkrJFlh9qyZ0fvI_eGP0TgYUC0Vcw,3394
5
- phone_a_friend_mcp_server/client/__init__.py,sha256=fsa8DXjz4rzYXmOUAdLdTpTwPSlZ3zobmBGXqnCEaWs,47
6
- phone_a_friend_mcp_server/tools/__init__.py,sha256=jtuvmcStXzbaM8wuhOKC8M8mBqDjHr-ypZ2ct1Rgi7Q,46
7
- phone_a_friend_mcp_server/tools/base_tools.py,sha256=DMjFq0E3TO9a9I7QY4wQ_B4-SntdXzSZzrYymFzSmVE,765
8
- phone_a_friend_mcp_server/tools/fax_tool.py,sha256=vzcGITygR49q9cu7Fw7SYcER7u_bKY6FKfvwBGKrRGs,7573
9
- phone_a_friend_mcp_server/tools/phone_tool.py,sha256=zvZOU9TgC7PR6nm7rj13PPH0dRnBN9XYk2bf2frIWpE,8356
10
- phone_a_friend_mcp_server/tools/tool_manager.py,sha256=VVtENC-n3D4GV6Cy3l9--30SJi06mJdyEiG7F_mfP7I,1474
11
- phone_a_friend_mcp_server-0.1.0.dist-info/METADATA,sha256=jXvQP4I_B2uhleQWo-gIcvWntCEJfeVe0Bz2VxLI_sE,10048
12
- phone_a_friend_mcp_server-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- phone_a_friend_mcp_server-0.1.0.dist-info/entry_points.txt,sha256=c_08XI-vG07VmUT3mtzyuCQjaus5l1NBl4q00Q3jLug,86
14
- phone_a_friend_mcp_server-0.1.0.dist-info/licenses/LICENSE,sha256=-8bInetillKZC0qZDT8RWYIOrph3HIU5cr5N4Pg7bBE,1065
15
- phone_a_friend_mcp_server-0.1.0.dist-info/RECORD,,