Skip to main content
Glama

sheets_check_access

Verify spreadsheet access permissions to determine allowed operations. Input the spreadsheet ID to retrieve detailed access information.

Instructions

Check access permissions for a spreadsheet. Returns information about what operations are allowed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spreadsheetIdYesThe ID of the spreadsheet to check access for

Implementation Reference

  • The core handler function that implements the tool logic: parses input, authenticates with Google Sheets API, checks read/write permissions by attempting API calls, handles errors, and returns permission status and recommendations.
    export async function handleCheckAccess(input: any) {
      try {
        const { spreadsheetId } = CheckAccessSchema.parse(input);
        const sheets = await getAuthenticatedClient();
    
        const permissions = {
          canRead: false,
          canWrite: false,
          canShare: false,
          isOwner: false,
          error: null as string | null,
        };
    
        try {
          // Try to read spreadsheet metadata
          const response = await sheets.spreadsheets.get({
            spreadsheetId,
            fields: 'properties.title,sheets.properties.sheetId,sheets.properties.title',
          });
    
          permissions.canRead = true;
    
          // Try to create a test request (but don't execute it) to check write permissions
          try {
            // Test write access by trying to prepare a values update
            await sheets.spreadsheets.values.update(
              {
                spreadsheetId,
                range: 'A1',
                valueInputOption: 'RAW',
                requestBody: {
                  values: [['']],
                },
              },
              {
                // Use validateOnly to not actually write
                params: {
                  validateOnly: true,
                },
              }
            );
            permissions.canWrite = true;
          } catch (writeError: any) {
            if (writeError.code === 403) {
              permissions.canWrite = false;
            } else if (writeError.code !== 400) {
              permissions.canWrite = true;
            }
          }
    
          return {
            spreadsheetId,
            title: response.data.properties?.title || 'Unknown',
            permissions,
            sheets:
              response.data.sheets?.map((sheet: any) => ({
                sheetId: sheet.properties?.sheetId,
                title: sheet.properties?.title,
              })) || [],
            recommendation: permissions.canWrite
              ? 'You have full read/write access to this spreadsheet.'
              : 'You have read-only access to this spreadsheet. To write data, the spreadsheet owner needs to grant you Editor permissions.',
          };
        } catch (error: any) {
          if (error.code === 404) {
            permissions.error = 'Spreadsheet not found. Check if the ID is correct.';
          } else if (error.code === 403) {
            permissions.error =
              'Access denied. The spreadsheet needs to be shared with your service account.';
          } else {
            permissions.error = error.message || 'Unknown error occurred';
          }
    
          return {
            spreadsheetId,
            permissions,
            error: permissions.error,
            recommendation:
              'Share the spreadsheet with your service account email and grant appropriate permissions.',
          };
        }
      } catch (error) {
        return handleError(error);
      }
    }
  • Zod schema for input validation and the Tool definition including name, description, and inputSchema for MCP protocol compliance.
    const CheckAccessSchema = z.object({
      spreadsheetId: z.string().describe('The ID of the spreadsheet to check access for'),
    });
    
    export const checkAccessTool: Tool = {
      name: 'sheets_check_access',
      description:
        'Check access permissions for a spreadsheet. Returns information about what operations are allowed.',
      inputSchema: {
        type: 'object',
        properties: {
          spreadsheetId: {
            type: 'string',
            description: 'The ID of the spreadsheet to check access for',
          },
        },
        required: ['spreadsheetId'],
      },
    };
  • src/index.ts:33-33 (registration)
    Registration of the tool handler in the toolHandlers Map used for executing called tools.
    ['sheets_check_access', tools.handleCheckAccess],
  • src/index.ts:68-68 (registration)
    Registration of the tool definition in the allTools array used for listing available tools.
    tools.checkAccessTool,
  • Re-export of the tool and handler from check-access module for barrel import in main index.
    export * from './check-access.js';
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns 'information about what operations are allowed,' which implies a read-only operation, but does not specify details like authentication requirements, rate limits, error handling, or the format of the returned information. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 concise and front-loaded, consisting of two clear sentences that directly state the tool's purpose and what it returns. There is no wasted language, and every sentence earns its place by providing essential information efficiently.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It does not explain the return values in detail, such as the structure or types of access permissions returned, nor does it cover behavioral aspects like error cases. For a tool that interacts with permissions, more context is needed to ensure proper usage.

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, with the parameter 'spreadsheetId' clearly documented. The description does not add any additional meaning beyond what the schema provides, such as explaining valid ID formats or examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 tool's purpose: 'Check access permissions for a spreadsheet.' It specifies the verb ('check') and resource ('spreadsheet'), but does not explicitly differentiate it from sibling tools like 'sheets_get_metadata', which might also provide some access-related information. The description is specific but lacks sibling distinction.

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. It does not mention prerequisites, such as needing valid spreadsheet IDs, or compare it to sibling tools like 'sheets_get_metadata' that might overlap in functionality. Without such context, users may struggle to select the appropriate 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

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/freema/mcp-gsheets'

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