Skip to content

Commit a47fcbe

Browse files
authored
Merge pull request #234 from IBM/code-stuff
Code stuff
2 parents 4e7f095 + e42e882 commit a47fcbe

9 files changed

Lines changed: 231 additions & 166 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ Global options available for all modes and commands:
314314
- `--dashboard`: Launch a real-time browser dashboard UI alongside chat mode
315315
- `--attach`: Attach files to the first message (repeatable: `--attach img.png --attach code.py`)
316316
- `--plan-tools`: Enable model-driven planning — the LLM autonomously creates and executes multi-step plans
317+
- `--no-tools`: Disable MCP tool calling entirely — chat directly with the LLM without connecting to any MCP servers
317318

318319
### Environment Variables
319320

docs/COMMANDS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,24 @@ The model calls these when it determines a task requires multi-step coordination
352352

353353
See [PLANNING.md](./PLANNING.md) for full documentation.
354354

355+
### Direct LLM Chat (No Tools)
356+
357+
Skip MCP server connections entirely and chat directly with the LLM:
358+
359+
```bash
360+
# No tool calling — MCP servers are not connected
361+
mcp-cli --no-tools
362+
mcp-cli --no-tools --provider openai --model gpt-4o
363+
mcp-cli chat --no-tools --provider anthropic --model claude-sonnet-4-6
364+
```
365+
366+
When `--no-tools` is set:
367+
- No MCP servers are initialized (no network connections attempted)
368+
- The LLM receives no tool definitions
369+
- The model responds conversationally only
370+
371+
This is useful when you want a fast, lightweight chat session without the overhead of server connections, or when using a model that handles tools poorly.
372+
355373
### Token Usage
356374

357375
Track API token consumption across your conversation:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mcp-cli"
7-
version = "0.19"
7+
version = "0.20"
88
description = "A cli for the Model Context Provider"
99
requires-python = ">=3.11"
1010
readme = "README.md"

server_config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@
9191
},
9292
"view_demo": {
9393
"url": "https://mcp-view-demo.fly.dev/mcp"
94+
},
95+
"pdf": {
96+
"command": "uv",
97+
"args": ["--directory", "/Users/christopherhay/chris-source/chuk-ai/mcp-servers/chuk-mcp-pdf", "run", "chuk-mcp-pdf", "stdio"]
98+
},
99+
"code-raptor": {
100+
"command": "uv",
101+
"args": [
102+
"run",
103+
"--directory", "/Users/christopherhay/chris-source/chuk-ai/mcp-servers/chuk-mcp-code-raptor",
104+
"chuk-mcp-code-raptor", "stdio"
105+
]
94106
}
95107
}
96108
}

src/mcp_cli/chat/chat_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def __init__(
152152
self.openai_tools: list[dict[str, Any]] = []
153153
self.tool_name_mapping: dict[str, str] = {}
154154
self._tool_index: dict[str, ToolInfo] = {}
155+
self.no_tools: bool = False
155156

156157
logger.debug(f"ChatContext created with {self.provider}/{self.model}")
157158

src/mcp_cli/chat/chat_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ async def handle_chat_mode(
5555
agent_id: str = "default",
5656
multi_agent: bool = False,
5757
initial_attachments: list[str] | None = None,
58+
no_tools: bool = False,
5859
) -> bool:
5960
"""
6061
Launch the interactive chat loop with streaming support.
@@ -131,6 +132,8 @@ def on_progress(msg: str) -> None:
131132
output.error("Failed to initialize chat context.")
132133
return False
133134

135+
ctx.no_tools = no_tools
136+
134137
# Stage initial attachments from --attach CLI flag
135138
if initial_attachments:
136139
from mcp_cli.chat.attachments import process_local_file

src/mcp_cli/chat/conversation.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,22 @@ async def process_conversation(self, max_turns: int = 100):
209209
return
210210

211211
# Ensure OpenAI tools are loaded for function calling
212-
if not getattr(self.context, "openai_tools", None):
213-
await self._load_tools()
212+
if not getattr(self.context, "no_tools", False):
213+
if not getattr(self.context, "openai_tools", None):
214+
await self._load_tools()
214215

215-
# Inject internal tools (plan, VM, memory) even when
216-
# openai_tools were pre-loaded by ChatContext.
217-
await self._inject_internal_tools()
216+
# Inject internal tools (plan, VM, memory) even when
217+
# openai_tools were pre-loaded by ChatContext.
218+
await self._inject_internal_tools()
218219

219220
# REMOVED: Sanitization logic - now handled by universal tool compatibility
220221
# The OpenAI client automatically handles tool name sanitization and restoration
221222

222-
# Always pass tools - let the model decide what to do
223-
tools_for_completion = self.context.openai_tools
223+
# Pass tools unless --no-tools was requested
224+
if getattr(self.context, "no_tools", False):
225+
tools_for_completion = None
226+
else:
227+
tools_for_completion = self.context.openai_tools
224228
logger.debug(
225229
f"Passing {len(tools_for_completion) if tools_for_completion else 0} tools to completion"
226230
)

src/mcp_cli/main.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ def main_callback(
175175
"--attach",
176176
help="Attach files to the first message (repeatable: --attach img.png --attach code.py).",
177177
),
178+
no_tools: bool = typer.Option(
179+
False,
180+
"--no-tools",
181+
help="Disable tool calling — chat with the LLM directly without MCP tools.",
182+
),
178183
) -> None:
179184
"""MCP CLI - If no subcommand is given, start chat mode."""
180185

@@ -383,8 +388,11 @@ async def _start_chat():
383388
logger.debug("Initializing tool manager")
384389
from mcp_cli.run_command import _init_tool_manager
385390

391+
# --no-tools: skip MCP server connections entirely
392+
_servers = [] if no_tools else servers
393+
_server_names = {} if no_tools else server_names
386394
tm = await _init_tool_manager(
387-
config_file, servers, server_names, init_timeout, runtime_config
395+
config_file, _servers, _server_names, init_timeout, runtime_config
388396
)
389397

390398
logger.debug("Starting chat mode handler")
@@ -407,6 +415,7 @@ async def _start_chat():
407415
dashboard_port=dashboard_port,
408416
multi_agent=multi_agent,
409417
initial_attachments=attach,
418+
no_tools=no_tools,
410419
)
411420
logger.debug(f"Chat mode completed with success: {success}")
412421
except asyncio.TimeoutError:
@@ -536,6 +545,11 @@ def _chat_command(
536545
"--attach",
537546
help="Attach files to the first message (repeatable: --attach img.png --attach code.py).",
538547
),
548+
no_tools: bool = typer.Option(
549+
False,
550+
"--no-tools",
551+
help="Disable tool calling — chat with the LLM directly without MCP tools.",
552+
),
539553
) -> None:
540554
"""Start chat mode (same as default behavior without subcommand)."""
541555
# Re-configure logging based on user options
@@ -655,8 +669,11 @@ async def _start_chat():
655669
logger.debug("Initializing tool manager")
656670
from mcp_cli.run_command import _init_tool_manager
657671

672+
# --no-tools: skip MCP server connections entirely
673+
_servers = [] if no_tools else servers
674+
_server_names = {} if no_tools else server_names
658675
tm = await _init_tool_manager(
659-
config_file, servers, server_names, init_timeout
676+
config_file, _servers, _server_names, init_timeout
660677
)
661678

662679
logger.debug("Starting chat mode handler")
@@ -676,6 +693,7 @@ async def _start_chat():
676693
dashboard_port=dashboard_port,
677694
multi_agent=multi_agent,
678695
initial_attachments=attach,
696+
no_tools=no_tools,
679697
)
680698
logger.debug(f"Chat mode completed with success: {success}")
681699
except asyncio.TimeoutError:

0 commit comments

Comments
 (0)