Skip to main content
Glama

manage_projects

Register or unregister projects for indexing to enable semantic search across Claude Code conversations. Use list to view project status.

Instructions

Manage which projects are registered for indexing. Use 'list' to see all projects on disk and their registration status. Use 'add' to register a project for indexing. Use 'remove' to unregister. Projects must be registered before they can be indexed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
projectNo

Implementation Reference

  • The primary handler for the 'manage_projects' tool. It executes add/remove/list actions on projects.
    export async function handleManageProjects(
      db: Database.Database,
      params: ManageProjectsParams
    ): Promise<{ content: Array<{ type: string; text: string }> }> {
      const config = loadUserConfig();
      const projectsBaseDir = process.env.CLAUDE_PROJECTS_DIR ?? CONFIG.claudeProjectsDir;
      const allProjects = scanProjects(projectsBaseDir);
    
      if (params.action === "list") {
        const projectList = allProjects.map((p) => {
          const sessions = scanSessions(p.dirPath);
          const isRegistered = config.indexed_projects.includes(p.dirName);
          return {
            dir_name: p.dirName,
            name: p.name,
            session_count: sessions.length,
            registered: isRegistered,
          };
        });
    
        // Sort: registered first, then by session count
        projectList.sort((a, b) => {
          if (a.registered !== b.registered) return a.registered ? -1 : 1;
          return b.session_count - a.session_count;
        });
    
        // Hide projects with 0 sessions (unless registered)
        const visible = projectList.filter((p) => p.session_count > 0 || p.registered);
        const hidden = projectList.length - visible.length;
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              total_projects: visible.length,
              registered_count: visible.filter((p) => p.registered).length,
              hidden_empty: hidden > 0 ? `${hidden} projects with 0 sessions hidden` : undefined,
              projects: visible,
              hint: "Use action 'add' with a project name to register for indexing. Use 'remove' to unregister.",
            }, null, 2),
          }],
        };
      }
    
      if (params.action === "add") {
        if (!params.project) {
          return {
            content: [{ type: "text", text: JSON.stringify({ error: "project parameter is required for 'add' action" }) }],
          };
        }
    
        // Exact match first (by dir_name or name)
        const exact = allProjects.filter(
          (p) =>
            p.dirName === params.project! ||
            p.name.toLowerCase() === params.project!.toLowerCase()
        );
        const matches = exact.length > 0 ? exact : allProjects.filter(
          (p) =>
            p.name.toLowerCase().includes(params.project!.toLowerCase()) ||
            p.dirName.toLowerCase().includes(params.project!.toLowerCase())
        );
    
        if (matches.length === 0) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: `No project matching "${params.project}" found.`,
                available: allProjects.filter((p) => scanSessions(p.dirPath).length > 0).map((p) => p.name),
              }),
            }],
          };
        }
    
        // If multiple matches, don't auto-add — return candidates for user to pick
        if (matches.length > 1) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                status: "multiple_matches",
                message: `"${params.project}" matched ${matches.length} projects. Please be more specific or use the exact dir_name.`,
                matches: matches.map((m) => ({
                  dir_name: m.dirName,
                  name: m.name,
                  session_count: scanSessions(m.dirPath).length,
                })),
              }),
            }],
          };
        }
    
        // Exactly 1 match — add it
        const match = matches[0];
        if (config.indexed_projects.includes(match.dirName)) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({ status: "ok", message: `${match.name} is already registered.`, total_registered: config.indexed_projects.length }),
            }],
          };
        }
    
        config.indexed_projects.push(match.dirName);
        saveUserConfig(config);
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              status: "ok",
              added: [match.name],
              total_registered: config.indexed_projects.length,
              message: `Added ${match.name} to indexing list. Run 'index' to start indexing.`,
            }),
          }],
        };
      }
    
      if (params.action === "remove") {
        if (!params.project) {
          return {
            content: [{ type: "text", text: JSON.stringify({ error: "project parameter is required for 'remove' action" }) }],
          };
        }
    
        // Block remove during active indexing to prevent DB conflicts
        if (getIndexProgress().running) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: "Cannot remove projects while indexing is in progress. Wait for indexing to complete or check status.",
              }),
            }],
          };
        }
    
        // Find which dir_names will be removed
        const removedDirNames: string[] = [];
        config.indexed_projects = config.indexed_projects.filter(
          (dirName) => {
            const proj = allProjects.find((p) => p.dirName === dirName);
            const name = proj?.name || dirName;
            const shouldRemove =
              name.toLowerCase().includes(params.project!.toLowerCase()) ||
              dirName.toLowerCase().includes(params.project!.toLowerCase());
            if (shouldRemove) removedDirNames.push(dirName);
            return !shouldRemove;
          }
        );
    
        saveUserConfig(config);
    
        // Delete indexed data from DB for removed projects
        let chunksDeleted = 0;
        let sessionsDeleted = 0;
        for (const dirName of removedDirNames) {
          const project = db.prepare("SELECT id FROM projects WHERE dir_name = ?").get(dirName) as { id: number } | undefined;
          if (project) {
            const sessions = db.prepare("SELECT id FROM sessions WHERE project_id = ?").all(project.id) as { id: number }[];
            for (const session of sessions) {
              deleteSessionChunks(db, session.id);
              chunksDeleted++;
            }
            sessionsDeleted += sessions.length;
            db.prepare("DELETE FROM sessions WHERE project_id = ?").run(project.id);
            db.prepare("DELETE FROM projects WHERE id = ?").run(project.id);
          }
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              status: "ok",
              removed_count: removedDirNames.length,
              sessions_deleted: sessionsDeleted,
              total_registered: config.indexed_projects.length,
              message: removedDirNames.length > 0
                ? `Removed ${removedDirNames.length} project(s) and deleted ${sessionsDeleted} session(s) from index.`
                : "No matching projects found in the registered list.",
            }),
          }],
        };
      }
    
      return {
        content: [{ type: "text", text: JSON.stringify({ error: "Invalid action. Use 'add', 'remove', or 'list'." }) }],
      };
    }
  • Input parameter validation schema for the 'manage_projects' tool.
    export interface ManageProjectsParams {
      action: "add" | "remove" | "list";
      project?: string;
    }
Behavior3/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 explains the three discrete actions and the registration requirement, but doesn't mention permissions needed, whether changes are reversible, rate limits, or what the response looks like. For a mutation tool with zero annotation coverage, this leaves significant gaps.

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 efficiently structured with three sentences: an overview statement, specific action explanations, and a prerequisite. Every sentence adds value with no redundant information, making it easy to parse and understand.

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

Completeness3/5

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

For a 2-parameter tool with no annotations and no output schema, the description provides good purpose and usage guidance but lacks details about response format, error conditions, and the exact format of the 'project' parameter. It's adequate but has clear gaps in behavioral transparency.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate. It explains the meaning of the 'action' parameter values ('list', 'add', 'remove') and implies the 'project' parameter is used with 'add' and 'remove' actions. However, it doesn't specify what format the 'project' parameter expects (path, name, ID).

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 with specific verbs ('manage', 'list', 'add', 'remove') and resources ('projects', 'indexing'), distinguishing it from sibling tools like 'index' or 'search'. It explains that this tool handles registration status for indexing, not the indexing process itself.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use each action ('list' to see status, 'add' to register, 'remove' to unregister) and includes a prerequisite statement ('Projects must be registered before they can be indexed') that helps differentiate from the 'index' sibling tool.

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/hyunjae-labs/lore'

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