Skip to main content
Glama

Activate Project

activate_project
Read-only

Activate a registered project by name or directory path to prepare it for development operations within the Serena MCP server environment.

Instructions

Activates the project with the given name or path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesThe name of a registered project to activate or a path to a project directory.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler for the 'activate_project' tool. This Tool subclass defines the apply method executed when the tool is called. It delegates to the agent's activate_project_from_path_or_name method and appends an activation message.
    class ActivateProjectTool(Tool, ToolMarkerDoesNotRequireActiveProject):
        """
        Activates a project based on the project name or path.
        """
    
        def apply(self, project: str) -> str:
            """
            Activates the project with the given name or path.
    
            :param project: the name of a registered project to activate or a path to a project directory
            """
            active_project = self.agent.activate_project_from_path_or_name(project)
            result = active_project.get_activation_message()
            result += "\nIMPORTANT: If you have not yet read the 'Serena Instructions Manual', do it now before continuing!"
            return result
  • Core helper method called by the tool handler to load a project from path or name (autogenerating if needed) and activate it by calling _activate_project.
    def activate_project_from_path_or_name(self, project_root_or_name: str) -> Project:
        """
        Activate a project from a path or a name.
        If the project was already registered, it will just be activated.
        If the argument is a path at which no Serena project previously existed, the project will be created beforehand.
        Raises ProjectNotFoundError if the project could neither be found nor created.
    
        :return: a tuple of the project instance and a Boolean indicating whether the project was newly
            created
        """
        project_instance: Project | None = self.load_project_from_path_or_name(project_root_or_name, autogenerate=True)
        if project_instance is None:
            raise ProjectNotFoundError(
                f"Project '{project_root_or_name}' not found: Not a valid project name or directory. "
                f"Existing project names: {self.serena_config.project_names}"
            )
        self._activate_project(project_instance)
        return project_instance
  • Internal helper method that performs the actual project activation: sets the active project, updates active tools, schedules language server init if needed, and invokes activation callback.
    def _activate_project(self, project: Project) -> None:
        log.info(f"Activating {project.project_name} at {project.project_root}")
        self._active_project = project
        self._update_active_tools()
    
        def init_language_server_manager() -> None:
            # start the language server
            with LogTime("Language server initialization", logger=log):
                self.reset_language_server_manager()
    
        # initialize the language server in the background (if in language server mode)
        if self.is_using_language_server():
            self.issue_task(init_language_server_manager)
    
        if self._project_activation_callback is not None:
            self._project_activation_callback()
  • ToolRegistry automatically discovers and registers all Tool subclasses in the serena.tools package, including ActivateProjectTool, via iter_subclasses(Tool). This method provides the list used to instantiate tools.
    return list(t.tool_class for t in self._tool_dict.values())
  • The schema (JSON schema for MCP tool) is derived from the apply method's signature and docstring using func_metadata. This class method extracts the metadata statically.
    def get_apply_fn_metadata_from_cls(cls) -> FuncMetadata:
Behavior3/5

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

Annotations indicate readOnlyHint=true and destructiveHint=false, which the description does not contradict. The description adds minimal behavioral context by implying activation of a project, but it doesn't elaborate on effects like environment changes or permissions needed. With annotations covering safety, the description provides some value but not rich behavioral details.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured for quick understanding.

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

Completeness4/5

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

Given the tool's moderate complexity (activation operation), high schema coverage, annotations, and the presence of an output schema, the description is reasonably complete. It covers the basic action but could benefit from more context on outcomes or integration with sibling tools, though the structured data reduces the burden on the description.

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

Parameters3/5

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

The input schema has 100% description coverage, clearly documenting the 'project' parameter. The description adds no additional meaning beyond the schema, such as examples or constraints, but since the schema is comprehensive, a baseline score of 3 is appropriate as the description doesn't compensate unnecessarily.

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

Purpose4/5

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

The description clearly states the action ('activates') and the resource ('the project with the given name or path'), making the purpose specific and understandable. However, it does not differentiate this tool from sibling tools like 'switch_modes' or 'get_current_config', which might relate to project state changes, so it doesn't fully distinguish from alternatives.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, such as 'switch_modes' or 'get_current_config', nor does it mention prerequisites like needing a registered project. It lacks explicit when/when-not instructions or named alternatives, leaving usage context unclear.

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/oraios/serena'

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