Skip to content

read_cell returns source code as char arrays #92

@2008sliu

Description

@2008sliu

Description

When sending a jsonrpc to the server with type read_cell, the response contains the source code with one-char per line. Is this desired behavior or it is a bug?

{
  "jsonrpc": "2.0",
  "id": 11,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\n  \"index\": 0,\n  \"type\": \"code\",\n  \"source\": [\n    \"i\",\n    \"m\",\n    \"p\",\n    \"o\",\n    \"r\",\n    \"t\",\n    \" \",\n    \"n\",\n    \"u\",\n    \"m\",\n    \"p\",\n    \"y\",\n    \" \",\n    \"a\",\n    \"s\",\n    \" \",\n    \"n\",\n    \"p\",\n    \"\\n\",\n    \"i\",\n    \"m\",\n    \"p\",\n    \"o\",\n    \"r\",\n    \"t\",\n    \" \",\n    \"m\",\n    \"a\",\n    \"t\",\n    \"p\",\n    \"l\",\n    \"o\",\n    \"t\",\n    \"l\",\n    \"i\",\n    \"b\",\n    \".\",\n    \"p\",\n    \"y\",\n    \"p\",\n    \"l\",\n    \"o\",\n    \"t\",\n    \" \",\n    \"a\",\n    \"s\",\n    \" \",\n    \"p\",\n    \"l\",\n    \"t\"\n  ],\n  \"outputs\": []\n}"
      }
    ],
    "structuredContent": {
      "index": 0,
      "type": "code",
      "source": [
        "i",
        "m",
        "p",
        "o",
        "r",
        "t",
        " ",
        "n",
        "u",
        "m",
        "p",
        "y",
        " ",
        "a",
        "s",
        " ",
        "n",
        "p",
        "\n",
        "i",
        "m",
        "p",
        "o",
        "r",
        "t",
        " ",
        "m",
        "a",
        "t",
        "p",
        "l",
        "o",
        "t",
        "l",
        "i",
        "b",
        ".",
        "p",
        "y",
        "p",
        "l",
        "o",
        "t",
        " ",
        "a",
        "s",
        " ",
        "p",
        "l",
        "t"
      ],
      "outputs": []
    },
    "isError": false
  }
}

Reproduce

  1. Start a jupyter server and start a kernel with doc a.ipynb, add a new cell (cell with index 0) with the following content and execute it

    import numpy as np
    import matplotlib.pyplot as plt
    
  2. Directly run jupyter-mcp-server start --transport=stdio --start-new-runtime=False | tee mcp.log with the environment variables set correctly

  3. In the stdin of jupyter-mcp-server, type the following (can copy and paste) to

    {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"manual-client","version":"1.0.0"}}}
    {"jsonrpc":"2.0","method":"notifications/initialized"}
    {"jsonrpc":"2.0","id":11,"method":"tools/call","params":{"name":"read_cell","arguments":{"cell_index":0}}}
    
  4. run tail -n1 mcp.log | jq to see the output

Expected behavior

The source field of the output should show the source code in lines

Context

  • Datalayer version: datalayer_pycrdt 0.12.17
  • Operating System and version: ubuntu
  • Browser and version:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions