serena.agent#
Source code: serena/agent.py
The Serena Model Context Protocol (MCP) Server
- class AvailableTools(tools)[source]#
Bases:
objectRepresents the set of available/exposed tools of a SerenaAgent.
- Parameters:
tools (list[Tool]) – the list of available tools
- tool_names#
the list of available tool names, sorted alphabetically
- class ToolSet(tool_names)[source]#
Bases:
objectRepresents a set of tools by their names.
- Parameters:
tool_names (set[str])
- LEGACY_TOOL_NAME_MAPPING = {'replace_regex': 'replace_content'}#
maps legacy tool names to their new names for backward compatibility
- classmethod default()[source]#
- Returns:
the default tool set, which contains all tools that are enabled by default
- Return type:
- apply(*tool_inclusion_definitions)[source]#
Applies one or more tool inclusion definitions to this tool set, resulting in a new tool set.
- Parameters:
tool_inclusion_definitions (ToolInclusionDefinition) – the definitions to apply
- Returns:
a new tool set with the definitions applied
- Return type:
- class ProjectPromptProvisionStatus(newly_activated_mode_names=None)[source]#
Bases:
objectManages the status of the provision of project-specific prompts
- Parameters:
newly_activated_mode_names (set[str] | None) – list of mode names that have been newly activated (by dynamic project activation) and for which prompts must still be provided (either in the system prompt or via the activation message)
- class SessionStatus(
- mode_prompts_provided: bool = False,
- project_activation_message_provided: bool = False,
Bases:
object- Parameters:
mode_prompts_provided (bool)
project_activation_message_provided (bool)
- is_mode_prompt_already_provided(mode_name, session_id)[source]#
- Parameters:
mode_name (str) – the mode name
session_id (str) – the client session ID
- Returns:
whether the mode name was already provided (in a project-specific activation message) and therefore should not be included again (in the Serena instructions manual)
- Return type:
bool
- get_modes_with_prompts_to_be_provided_for_project_activation(
- session_id,
Gets the modes that have been newly activated and for which prompts still need to be provided (in dynamic project activation message).
- Param:
session_id: the client session ID
- Returns:
the modes
- Parameters:
session_id (str)
- Return type:
list[SerenaAgentMode]
- mark_mode_prompts_as_provided(session_id)[source]#
Marks the prompts for all newly activated modes as provided, so that they will not be included in the project activation message.
- Parameters:
session_id (str) – the client session ID
- Return type:
None