Skip to content

Commit

Permalink
Formatting and updating the changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jan 1, 2025
1 parent e523815 commit be0b695
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
> Features:
- [e523815] [Feature] Standalone MCP server script
- [5d138d5] [Feature] Separate MCP server and client processes

> Improvements:
- [cc51ead] [Improvement] Handle missing default model + optimizing the config calls
- [7fa1a6f] [Improvement] Handle interruption during MCP Server initialization
- [abbcd08] [Improvement] Better MCP server related error handling
- [cccf3a3] [Improvement] Proper conversation handling when interrupted with tools


---
2 changes: 1 addition & 1 deletion app-data/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "6.8.3"
version = "6.9.0"
15 changes: 9 additions & 6 deletions mcp_servers/mcp_tcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from mcp import ClientSession, StdioServerParameters, Tool
from mcp.client.stdio import stdio_client

from mcp_errors import (CommandNotFoundError, ConfigError, MCPError,
ServerInitError, ToolExecutionError)

Expand All @@ -21,15 +20,16 @@
logger.setLevel(logging.DEBUG) # Set the base logger level to DEBUG

# Create a FileHandler for DEBUG logs
file_handler = logging.FileHandler(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'mcp_tcp_server.log'),
mode='w')
file_handler = logging.FileHandler(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "mcp_tcp_server.log"), mode="w"
)
file_handler.setLevel(logging.DEBUG) # Log all messages (DEBUG and above) to the file
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
file_handler.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))

# Create a StreamHandler for INFO logs
stream_handler = logging.StreamHandler(sys.stdout)
stream_handler.setLevel(logging.INFO) # Only log INFO and above to the console
stream_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
stream_handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))

# Add both handlers to the logger
logger.addHandler(file_handler)
Expand All @@ -46,6 +46,7 @@
logger.error('"mcp_config.json.sample" is either missing or renamed, please update from source.')
exit(1)


class MCPServer:
def __init__(self, server_name, server_config):
self.server_name = server_name
Expand Down Expand Up @@ -77,6 +78,7 @@ async def cleanup(self):
self.logger.error(f"Error during client cleanup: {e}")
self.client = None


class MCPTCPServer:
def __init__(self, host: str = "localhost", port: int = 8765):
self.host = host
Expand Down Expand Up @@ -498,6 +500,7 @@ async def start(self):
await self.cleanup()
raise


if __name__ == "__main__":
server = MCPTCPServer()

Expand All @@ -508,4 +511,4 @@ async def main():
logger.info("\nShutting down server...")
await server.cleanup()

asyncio.run(main())
asyncio.run(main())

0 comments on commit be0b695

Please sign in to comment.