Repository navigation
Psse auto detect and stdio fix - #124
Open
sbblack-qualus wants to merge 2 commits into
Open
sbblack-qualus wants to merge 2 commits into
sbblack-qualus wants to merge 2 commits into
Conversation
qian-harvard
requested changes
Oct 22, 2026
qian-harvard
left a comment
Contributor
There was a problem hiding this comment.
Thanks for working on this. PSS/E auto-discovery and keeping PSS/E's report output off the MCP stream are both useful. Unfortunately the branch can't be merged as it stands. In the merge commit (2c9e052), the conflict in PSSE/psse_mcp.py was resolved by keeping your fork's copy of the file whole. That copy dates from March, so the PR reverts everything that has landed in the PSS/E server since then:
- The server no longer starts with the pinned SDK. It imports
from mcp.server.fastmcp import FastMCP, butpyproject.tomlpinsmcp>=2,<3, where that module doesn't exist. Main usesfrom mcp.server.mcpserver import MCPServer as FastMCP. With main merged in, pytest aborts at collection:tests/test_psse_server.pyandtests/test_sandbox.pyraiseModuleNotFoundError. - The security hardening from #57 is gone. That covers:
- the
_PROHIBITED_PSSPY_COMMANDSblocklist, solaunch_program,runrspnsfile,addmodellibraryand others become callable throughrun_psspy_command; - the
checked_pathsandbox on case and file arguments; - the identifier check in
lookup_psspy_command, solookup_psspy_command("../../pyproject")reads files outside the spec folder again.
- the
- PSS/E initialises at import time. Discovery and
psseinitrun on import and raise on any machine without PSS/E. Main made this lazy (_ensure_psse), and it reads thepowermcp configpaths (psse.python_lib/psse.bin), which this version drops. - The
open_casefixes from #94 are reverted. Theierrfrompsspy.caseis no longer checked, so a failed load reports success with the previous case's counts. - The
list_dynamic_output_channelsandread_dynamic_outputtools from #97/#98 are deleted.
On the two features themselves:
- Auto-detect.
- The candidate majors are hard-coded to
[36, 35], so PSS/E 37 is never found. PSSE_VERSION=36.2raisesValueError.- The manual override is silently ignored unless both env vars are set.
- The override defaults to
psse36, so a PSS/E 35 user getsNo module named 'psse36'.
- The candidate majors are hard-coded to
- stdout. mcp 2.x already redirects fd 1 to stderr when the stdio transport starts. A tool that
print()s oros.write(1, ...)s doesn't corrupt the JSON-RPC stream on main. The crash you saw looks like mcp 1.x behaviour. The part worth keeping is returning the captured text to the client (your_console_output), since otherwisepsspy.diffoutput only reaches stderr.
Could you open a fresh branch from current main and port just the new behaviour onto main's version of the file?
- Move discovery into
_resolve_psse_paths()so it stays lazy. Checkpowermcp configfirst, and don't cap the major version. - Keep the
_console_outputcapture insiderun_psspy_command. - Add tests to
tests/test_psse_server.pyusing its fakepsspy. CI doesn't have PSS/E, so those tests are what will cover this.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add functionality to auto discover the highest version of psse on the machine that has an appropriate psspy package matching the python version from which the MCP server was run. I would suggest doing some homework and selecting an MCP run command setup in your AI harness that runs the MCP server purposely in a version of python that matches a version of psse you have on your machine (PSSE >= 35).
There was also some strange behavior where the injection of report output from api calls like psspy.diff to stdout interfered with FastMCP and crashed the MCP server. I have added wrappers to attempt to keep PSSE output away from STDIO. It seems to be more stable now. I suspect that proper use of the redirect module might be a more eloquent solution, but this seems to work for now.