Skip to main content
Glama

Create Livy Session

livy_create_session

Create a Spark session for executing PySpark, Scala, or SparkR code in Microsoft Fabric. Initialize a session to run data processing and analytics tasks on specified workspace and lakehouse resources.

Instructions

Create a new Livy session for Spark code execution.

Creates a Spark session for executing PySpark, Scala, or SparkR code. Session creation can take 6+ minutes on first startup as Spark initializes. It's recommended to keep with_wait=True to ensure the session is ready before use.

Parameters: workspace_id: Fabric workspace ID (use list_workspaces tool to find by name). lakehouse_id: Fabric lakehouse ID (use list_items tool with item_type="Lakehouse"). environment_id: Optional Fabric environment ID for pre-installed libraries. kind: Session kind - 'pyspark' (default), 'scala', or 'sparkr'. conf: Optional Spark configuration as key-value pairs (e.g., {"spark.executor.memory": "4g"}). with_wait: If True (default), wait for session to become available before returning. timeout_seconds: Maximum time to wait for session availability (default: from config).

Returns: Dictionary with session details including id, state, kind, appId, appInfo, and log.

Example: ```python # Create a PySpark session result = livy_create_session( workspace_id="12345678-1234-1234-1234-123456789abc", lakehouse_id="87654321-4321-4321-4321-210987654321", kind="pyspark", with_wait=True )

if result.get("state") == "idle":
    session_id = result["id"]
    # Session is ready to execute code
```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspace_idYes
lakehouse_idYes
environment_idNo
kindNopyspark
confNo
with_waitNo
timeout_secondsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: the creation process ('can take 6+ minutes on first startup'), the recommendation to use 'with_wait=True' for readiness, and the return format ('Dictionary with session details'). It also implies this is a write operation (creating a session) and mentions timeouts. However, it lacks details on error handling, permissions, or rate limits, which are important for a creation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections: purpose, behavioral notes, parameters, returns, and an example. It is appropriately sized for a complex tool with 7 parameters. However, some sentences could be more concise (e.g., the parameter explanations are detailed but slightly verbose), and the example is lengthy, though it adds practical value. Overall, it is efficient but not perfectly minimal.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (7 parameters, no annotations, schema coverage 0%), the description is highly complete. It covers purpose, behavioral traits (like startup time and waiting), detailed parameter semantics, return values, and includes a practical example. With an output schema present, it doesn't need to explain return values in depth, but it still provides a summary. This makes it sufficient for an agent to understand and use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate fully. It provides detailed semantics for all 7 parameters: explains what each parameter represents (e.g., 'workspace_id: Fabric workspace ID'), gives usage tips (e.g., 'use list_workspaces tool to find by name'), lists options (e.g., 'kind: Session kind - 'pyspark' (default), 'scala', or 'sparkr''), and includes examples (e.g., 'conf: Optional Spark configuration as key-value pairs'). This adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Create a new Livy session for Spark code execution' and 'Creates a Spark session for executing PySpark, Scala, or SparkR code.' It specifies the exact action (create), resource (Livy/Spark session), and distinguishes it from sibling tools like livy_list_sessions, livy_close_session, etc., by focusing on creation rather than listing or closing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: for creating a session to execute Spark code. It mentions that 'Session creation can take 6+ minutes on first startup' and recommends 'with_wait=True to ensure the session is ready before use,' offering practical guidance. However, it does not explicitly state when not to use it or name alternatives (e.g., using existing sessions vs. creating new ones), which prevents a score of 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bablulawrence/ms-fabric-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server