Skip to content

Commit c9138c6

Browse files
committed
Release 0.1.2
1 parent af20a1f commit c9138c6

File tree

2 files changed

+91
-28
lines changed

2 files changed

+91
-28
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020

2121
---
2222

23+
## [0.1.2] - 2025-01-XX
24+
25+
### Added
26+
- **MCP Integration**: Full Model Context Protocol (MCP) client support with commands for server management (`/mcp-servers`, `/mcp-connect`, `/mcp-disconnect`), tools (`/mcp-tools`, `/mcp-call`), resources (`/mcp-resources`, `/mcp-read`), and prompts (`/mcp-prompts`, `/mcp-prompt`)
27+
- **MCP Documentation**: Complete MCP guides and tutorials (overview, integration reference, filesystem assistant, GitHub triage)
28+
- **MCP Examples**: Working implementations for filesystem assistant and GitHub triage copilot, plus configuration examples
29+
- **MCP Configuration**: Support for stdio, SSE, and WebSocket transports with multiple directory access for filesystem server
30+
- **MCP Error Handling**: Auto-connect for `/mcp-tools`, detailed error messages with troubleshooting tips
31+
32+
### Changed
33+
- `/mcp-tools` command now auto-connects to servers if not already connected
34+
- Improved MCP error messages and session management
35+
36+
### Fixed
37+
- Fixed `/mcp-tools` command failing when server not connected
38+
- Improved error handling for MCP connection and configuration issues
39+
40+
---
41+
2342
## [0.1.1] - 2025-11-27
2443

2544
### Added

dspy_code/commands/slash_commands.py

Lines changed: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,41 +1342,85 @@ def cmd_mcp_tools(self, args: list):
13421342
console.print()
13431343

13441344
try:
1345-
tools_by_server = asyncio.run(self.mcp_manager.list_tools(server_name))
1345+
self._run_mcp_async(self._mcp_tools_async(server_name))
1346+
except Exception as e:
1347+
from ..mcp.exceptions import MCPError, format_mcp_error
13461348

1347-
if not tools_by_server:
1348-
show_warning_message("No tools available")
1349-
console.print()
1350-
return
1349+
# Use formatted error for MCP errors
1350+
if isinstance(e, MCPError):
1351+
error_msg = format_mcp_error(e, verbose=True)
1352+
show_error_message(error_msg)
1353+
else:
1354+
# For other exceptions, show the error with details
1355+
error_parts = [f"Failed to list tools: {str(e) or type(e).__name__}"]
1356+
if hasattr(e, "__cause__") and e.__cause__:
1357+
error_parts.append(f"\nCause: {e.__cause__}")
1358+
show_error_message("\n".join(error_parts))
1359+
# Print traceback for debugging
1360+
import traceback
1361+
logger.debug("Error listing MCP tools", exc_info=True)
1362+
1363+
async def _mcp_tools_async(self, server_name: str | None):
1364+
"""Async helper for MCP tools listing."""
1365+
from ..mcp.exceptions import MCPConnectionError, MCPOperationError
1366+
1367+
# Auto-connect if server is specified but not connected
1368+
if server_name:
1369+
session = await self.mcp_manager.get_session(server_name)
1370+
if not session:
1371+
show_info_message(f"Connecting to '{server_name}'...")
1372+
try:
1373+
await self.mcp_manager.connect(server_name)
1374+
show_success_message(f"Connected to '{server_name}'")
1375+
except MCPConnectionError as e:
1376+
# Re-raise connection errors so they can be formatted properly
1377+
raise
1378+
except Exception as e:
1379+
# Wrap other connection errors
1380+
from ..mcp.exceptions import MCPConnectionError as MCPConnErr
1381+
raise MCPConnErr(
1382+
f"Failed to connect to '{server_name}': {e}",
1383+
server_name=server_name,
1384+
details={"error": str(e), "error_type": type(e).__name__},
1385+
)
13511386

1352-
for srv_name, tools in tools_by_server.items():
1353-
table = Table(title=f"Tools from '{srv_name}'")
1354-
table.add_column("Name", style="cyan")
1355-
table.add_column("Description", style="white")
1387+
try:
1388+
tools_by_server = await self.mcp_manager.list_tools(server_name)
1389+
except MCPOperationError:
1390+
# Re-raise operation errors so they can be formatted properly
1391+
raise
13561392

1357-
for tool in tools:
1358-
table.add_row(tool.name, tool.description or "")
1393+
if not tools_by_server:
1394+
show_warning_message("No tools available")
1395+
console.print()
1396+
return
13591397

1360-
console.print(table)
1361-
console.print()
1398+
for srv_name, tools in tools_by_server.items():
1399+
table = Table(title=f"Tools from '{srv_name}'")
1400+
table.add_column("Name", style="cyan")
1401+
table.add_column("Description", style="white")
13621402

1363-
# Show detailed schema for each tool
1364-
console.print("[bold]Tool Schemas:[/bold]")
1365-
for tool in tools:
1366-
console.print(f"\n[cyan]{tool.name}[/cyan]")
1367-
if tool.description:
1368-
console.print(f" Description: {tool.description}")
1369-
if hasattr(tool, "inputSchema") and tool.inputSchema:
1370-
import json
1371-
1372-
schema_str = json.dumps(tool.inputSchema, indent=2)
1373-
console.print(" Schema:")
1374-
console.print(f" [dim]{schema_str}[/dim]")
1375-
console.print()
1403+
for tool in tools:
1404+
table.add_row(tool.name, tool.description or "")
13761405

1406+
console.print(table)
13771407
console.print()
1378-
except Exception as e:
1379-
show_error_message(f"Failed to list tools: {e}")
1408+
1409+
# Show detailed schema for each tool
1410+
console.print("[bold]Tool Schemas:[/bold]")
1411+
for tool in tools:
1412+
console.print(f"\n[cyan]{tool.name}[/cyan]")
1413+
if tool.description:
1414+
console.print(f" Description: {tool.description}")
1415+
if hasattr(tool, "inputSchema") and tool.inputSchema:
1416+
import json
1417+
1418+
schema_str = json.dumps(tool.inputSchema, indent=2)
1419+
console.print(" Schema:")
1420+
console.print(f" [dim]{schema_str}[/dim]")
1421+
console.print()
1422+
1423+
console.print()
13801424

13811425
def cmd_mcp_call(self, args: list):
13821426
"""

0 commit comments

Comments
 (0)