Skip to main content
Glama

Sync Storage

sync_storage

Manually trigger git synchronization for the Knowledge MCP Server datastore to backup changes, resolve sync issues, or ensure data persistence before major operations. Handles uncommitted changes and push failures effectively.

Instructions

Force git add, commit, and push all changes in the knowledge datastore.

When to use this tool:

  • Manually triggering backup to remote

  • Ensuring changes are persisted

  • Before major operations

  • Resolving sync issues

  • Explicit backup request

Key features:

  • Commits ALL uncommitted changes

  • Pushes to configured remote

  • Auto-generates commit message

  • Handles push failures gracefully

  • Forces synchronization

You should:

  1. Check storage_status first

  2. Use when auto-sync fails

  3. Verify remote is configured

  4. Handle push failures appropriately

  5. Use sparingly (auto-sync usually works)

DO NOT use when:

  • No changes to commit

  • Remote not configured

  • Auto-sync is working fine

Returns: {success: bool, message: str, files_committed: int, pushed: bool, push_error?: str, commit_message: str}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Async handler method that executes the sync_storage tool: gets git status, commits changes if any with descriptive message, attempts to push to remote if configured, handles errors.
    async syncStorageAsync(): Promise<string> {
      const context = this.createContext('sync_storage', {});
    
      try {
        // Get current status before sync
        const { stdout: beforeStatus } = await gitCommandAsync(STORAGE_PATH, 'status', '--porcelain');
        const hasChanges = beforeStatus.trim().length > 0;
    
        if (!hasChanges) {
          // No changes to sync
          const result = {
            message: 'No changes to sync - working tree clean',
            files_committed: 0,
            pushed: false,
          };
          this.logSuccess('sync_storage', result, context);
          return this.formatSuccessResponse(result);
        }
    
        // Count files to be committed
        const filesCount = beforeStatus.trim().split('\n').length;
    
        // Perform auto-commit with a descriptive message
        const timestamp = new Date().toISOString();
        const commitMessage = `Sync storage: ${filesCount} file${filesCount > 1 ? 's' : ''} updated at ${timestamp}`;
        await autoCommitAsync(STORAGE_PATH, commitMessage);
    
        // Check if push was successful
        const hasRemote = await hasGitRemoteAsync(STORAGE_PATH);
        let pushed = false;
        let pushError: string | undefined;
    
        if (hasRemote) {
          try {
            await pushToOriginAsync(STORAGE_PATH);
            pushed = true;
          } catch (error) {
            pushError = error instanceof Error ? error.message : String(error);
          }
        }
    
        const result = {
          message: `Successfully committed ${filesCount} file${filesCount > 1 ? 's' : ''}`,
          files_committed: filesCount,
          pushed,
          push_error: pushError,
          commit_message: commitMessage,
        };
    
        this.logSuccess('sync_storage', { files_committed: filesCount, pushed }, context);
        return this.formatSuccessResponse(result);
      } catch (error) {
        const mcpError = new MCPError(
          MCPErrorCode.GIT_ERROR,
          `Failed to sync storage: ${error instanceof Error ? error.message : String(error)}`,
          { traceId: context.traceId }
        );
        this.logError('sync_storage', {}, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
  • Registers the sync_storage tool on the MCP server, with empty input schema, delegating execution to serverHandler.syncStorageAsync()
    server.registerTool(
      'sync_storage',
      {
        title: 'Sync Storage',
        description: TOOL_DESCRIPTIONS.sync_storage,
        inputSchema: {},
      },
      async () => {
        const result = await serverHandler.syncStorageAsync();
        return {
          content: [
            {
              type: 'text',
              text: result,
            },
          ],
        };
      }
    );
  • Synchronous version of the sync_storage handler with identical logic to the async version.
    syncStorage(): string {
      const context = this.createContext('sync_storage', {});
    
      try {
        // Get current status before sync
        const { stdout: beforeStatus } = gitCommand(STORAGE_PATH, 'status', '--porcelain');
        const hasChanges = beforeStatus.trim().length > 0;
    
        if (!hasChanges) {
          // No changes to sync
          const result = {
            message: 'No changes to sync - working tree clean',
            files_committed: 0,
            pushed: false,
          };
          this.logSuccess('sync_storage', result, context);
          return this.formatSuccessResponse(result);
        }
    
        // Count files to be committed
        const filesCount = beforeStatus.trim().split('\n').length;
    
        // Perform auto-commit with a descriptive message
        const timestamp = new Date().toISOString();
        const commitMessage = `Sync storage: ${filesCount} file${filesCount > 1 ? 's' : ''} updated at ${timestamp}`;
        autoCommit(STORAGE_PATH, commitMessage);
    
        // Check if push was successful
        const hasRemote = hasGitRemote(STORAGE_PATH);
        let pushed = false;
        let pushError: string | undefined;
    
        if (hasRemote) {
          try {
            pushToOrigin(STORAGE_PATH);
            pushed = true;
          } catch (error) {
            pushError = error instanceof Error ? error.message : String(error);
          }
        }
    
        const result = {
          message: `Successfully committed ${filesCount} file${filesCount > 1 ? 's' : ''}`,
          files_committed: filesCount,
          pushed,
          push_error: pushError,
          commit_message: commitMessage,
        };
    
        this.logSuccess('sync_storage', { files_committed: filesCount, pushed }, context);
        return this.formatSuccessResponse(result);
      } catch (error) {
        const mcpError = new MCPError(
          MCPErrorCode.GIT_ERROR,
          `Failed to sync storage: ${error instanceof Error ? error.message : String(error)}`,
          { traceId: context.traceId }
        );
        this.logError('sync_storage', {}, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
  • Tool description string used in the registration, providing usage guidelines and expected return format.
      sync_storage: `Force git add, commit, and push all changes in the knowledge datastore.
    
    When to use this tool:
    - Manually triggering backup to remote
    - Ensuring changes are persisted
    - Before major operations
    - Resolving sync issues
    - Explicit backup request
    
    Key features:
    - Commits ALL uncommitted changes
    - Pushes to configured remote
    - Auto-generates commit message
    - Handles push failures gracefully
    - Forces synchronization
    
    You should:
    1. Check storage_status first
    2. Use when auto-sync fails
    3. Verify remote is configured
    4. Handle push failures appropriately
    5. Use sparingly (auto-sync usually works)
    
    DO NOT use when:
    - No changes to commit
    - Remote not configured
    - Auto-sync is working fine
    
    Returns: {success: bool, message: str, files_committed: int, pushed: bool, push_error?: str, commit_message: str}`,
    };
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 behaviors: commits ALL uncommitted changes, pushes to remote, auto-generates commit messages, handles push failures gracefully, and forces synchronization. It also mentions operational considerations like using sparingly and checking remote configuration. The only minor gap is lack of explicit rate limit or permission requirements.

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 well-structured with clear sections (purpose, when to use, key features, recommendations, exclusions, return format). Every sentence adds value—no repetition or fluff. It's front-loaded with the core purpose and efficiently organized for quick scanning.

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 tool's complexity (mutating synchronization operation), no annotations, and no output schema, the description provides excellent completeness. It covers purpose, usage scenarios, behavioral traits, precautions, and explicitly documents the return value structure. This compensates fully for the lack of structured metadata.

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?

The input schema has 0 parameters with 100% coverage, so the baseline would be 3. The description adds value by implicitly confirming no parameters are needed ('Force... all changes'), which aligns with the schema. However, it doesn't explicitly state 'no parameters required,' which would have made it perfect.

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 specific action: 'Force git add, commit, and push all changes in the knowledge datastore.' It uses precise verbs (add, commit, push) and specifies the resource (knowledge datastore). It distinguishes itself from siblings like 'get_storage_status' by being an active synchronization tool rather than a status check.

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 with 'When to use this tool' (5 scenarios), 'You should' (5 recommendations), and 'DO NOT use when' (3 exclusions). It clearly differentiates from auto-sync and references sibling tools like 'get_storage_status' for prerequisite checks, offering comprehensive usage context.

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

Related 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/sven-borkert/knowledge-mcp'

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