serena.project_server#


class QueryProjectRequest(*, project_name, tool_name, tool_params_json)[source]#

Bases: BaseModel

Request model for the /query_project endpoint, matching the interface of QueryProjectTool.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:
  • project_name (str)

  • tool_name (str)

  • tool_params_json (str)

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ProjectServer(host='127.0.0.1', port=None)[source]#

Bases: object

A lightweight Flask server that exposes a SerenaAgent’s project querying capabilities via HTTP, using the LSP language server backend for symbolic retrieval.

Projects are loaded on demand when a query is made for them, and cached in memory for subsequent queries.

The server instantiates a SerenaAgent with default options and provides a /query_project endpoint whose interface matches QueryProjectTool.

Parameters:
  • host (str) – the host address to listen on.

  • port (int | None) – the port to listen on; if None, use default

run()[source]#

Run the server on the given host and port.

Return type:

None

class ProjectServerClient(host='127.0.0.1', port=24225, timeout=300)[source]#

Bases: object

Client for interacting with a running ProjectServer.

Upon instantiation, the client verifies that the server is reachable by sending a heartbeat request. If the server is not running, a ConnectionError is raised.

Parameters:
  • host (str) – the host address of the project server.

  • port (int) – the port of the project server.

  • timeout (int)

Raises:

ConnectionError – if the project server is not reachable.

query_project(project_name, tool_name, tool_params_json)[source]#

Query a project by executing a Serena tool in its context.

The interface matches QueryProjectTool.apply.

Parameters:
  • project_name (str) – the name of the project to query.

  • tool_name (str) – the name of the tool to execute. The tool must be read-only.

  • tool_params_json (str) – the parameters to pass to the tool, encoded as a JSON string.

Returns:

the tool’s result as a string.

Return type:

str