Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to use excel-mcp-server in stdio mode due to ValueError: I/O operation on closed file #42

Open
@AFA24SCM54D

Description

@AFA24SCM54D

I'm trying to integrate excel-mcp-server with a Python code through stdio mode, but I consistently get a ValueError related to stdin being closed unexpectedly.

Code snippet -

def call_excel_mcp_tool(command: dict, timeout: int = 15):
proc = subprocess.Popen(
["uvx", "excel-mcp-server", "stdio"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1 # Line-buffered
)

stdout_lines = []stderr_lines = []json_response = {}def read_stdout(pipe):    for line in pipe:        cleaned = line.strip()        stdout_lines.append(cleaned)        print("[MCP STDOUT]", cleaned)        try:            json_response.update(json.loads(cleaned))        except json.JSONDecodeError:            passdef read_stderr(pipe):    for line in pipe:        cleaned = line.strip()        stderr_lines.append(cleaned)        print("[MCP STDERR]", cleaned)threading.Thread(target=read_stdout, args=(proc.stdout,), daemon=True).start()threading.Thread(target=read_stderr, args=(proc.stderr,), daemon=True).start()try:    proc.stdin.write(json.dumps(command) + "\n")    proc.stdin.flush()    # Wait a bit instead of killing immediately    start_time = time.time()    while time.time() - start_time < timeout:        if json_response:            break        time.sleep(0.1)    proc.terminate()  # Graceful stop instead of killexcept Exception as e:    print("Exception:", e)    proc.kill()return json_response if json_response else {    "error": "No valid JSON response",    "stderr": stderr_lines,    "raw_stdout": stdout_lines}

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp