Skip to content

Fix code quality issues in LiteRT-LM MCP server#6

Merged
groupthinking merged 6 commits intomainfrom
copilot/sub-pr-5
Jan 29, 2026
Merged

Fix code quality issues in LiteRT-LM MCP server#6
groupthinking merged 6 commits intomainfrom
copilot/sub-pr-5

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

Addresses code review feedback on the LiteRT-LM MCP server implementation: unused imports, dead code, indentation inconsistencies, missing input validation, and error handling gaps.

Changes

Code cleanup:

  • Removed unused subprocess import
  • Removed dead try-except block with empty pass statement
  • Fixed indentation inconsistencies (4-space standard)

Input validation & security:

  • Added prompt validation (non-empty string check)
  • Added runtime backend parameter validation against allowed values ["cpu", "gpu", "npu"]
# Validate prompt parameter
if not prompt or not isinstance(prompt, str) or not prompt.strip():
    return {"status": "error", "message": "Invalid or empty prompt..."}

# Validate backend parameter
valid_backends = ["cpu", "gpu", "npu"]
if backend not in valid_backends:
    return {"status": "error", "message": f"Invalid backend '{backend}'..."}

Error handling robustness:

  • Added try-except for write pipe connection failures with fallback to stdout
  • Set writer = None on drain errors to prevent repeated failures

Documentation:

  • Updated README example from multimodal (unsupported) to text-only inference
  • Added note clarifying CLI wrapper limitations

Consistency:

  • Aligned Windows handling pattern with other MCP servers (cloudflare_server, code_analysis_server)
  • Standardized logging to f-strings

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
event-relay-web Error Error Jan 29, 2026 5:29pm
v0-uvai Error Error Jan 29, 2026 5:29pm

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Add LiteRT-LM MCP Server Fix code quality issues in LiteRT-LM MCP server Jan 27, 2026
Copilot AI requested a review from groupthinking January 27, 2026 17:22
Base automatically changed from add-litert-mcp-server-5067712973603937642 to main January 27, 2026 17:43
@groupthinking groupthinking added the dependencies Pull requests that update a dependency file label Jan 27, 2026
@groupthinking groupthinking marked this pull request as ready for review January 29, 2026 17:27
Copilot AI review requested due to automatic review settings January 29, 2026 17:27
@groupthinking groupthinking merged commit afc05ad into main Jan 29, 2026
11 of 15 checks passed
@groupthinking groupthinking deleted the copilot/sub-pr-5 branch January 29, 2026 17:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines the LiteRT-LM MCP server by cleaning up unused/dead code, tightening input validation, hardening error handling around subprocess and stdio, and aligning the README with the current text-only CLI capabilities.

Changes:

  • Added explicit validation for prompt and backend arguments, returning structured error responses for invalid input.
  • Simplified and clarified I/O handling in the main loop, including safer writer drain handling and a consistent fallback to sys.stdout.write.
  • Updated README usage example and documentation to reflect text-only support and clarify multimodal limitations for the CLI wrapper.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
mcp-servers/litert-mcp/server.py Cleans up unused code, adds prompt/backend validation, and hardens async stdio writing/drain error handling for more robust MCP request processing.
mcp-servers/litert-mcp/README.md Updates the run_inference example and notes to emphasize text-only inference and clarify multimodal limitations of the current CLI wrapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants