Skip to content

Error with extism.input_json() #37

Description

@G4Vi

Attempting to develop a python https://mcp.run plugin, after extism.input(CallToolRequest) did not work as method is not optional due to the bindgen not supporting required: dylibso/xtp-python-bindgen#16 (comment), I decided to abandon strong typing and load input into a dict.

I switched the code of call in __init__.py to.

    data = extism.input_json()
    res = plugin.call(data)

Unfortunately this fails:

gavin@Gavins-MacBook-Pro obsidian % EXTISM_ENABLE_WASI_OUTPUT=1 xtp plugin call plugin.wasm call --input='{
    "params": {
        "name": "greet",
        "arguments":{}
    }
}' --wasi
2024/12/18 17:34:50 beginning of call
thread '<unnamed>' panicked at src/lib.rs:58:6:
called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'TypeError'>, value: TypeError('issubclass() arg 1 must be a class'), traceback: Some(<traceback object at 0x68d0a8>) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: wasm error: unreachable
wasm stack trace:
        .$10486(i32,i32,i32,i32,i32)
        .$10772(i32,i32)
        .$10792(i32,i32,i32,i32,i32)
        .$10827(i32,i32) i32
        .$10846() i32
returned non-zero exit code: 1
Log file: /Users/gavin/Library/Caches/xtp/xtp-1734561289-6311.log

I am able to work around this with import json and data = json.loads(extism.input_str()) instead of using extism's function.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions