Get Scopes
get_scopesRetrieve available permission scopes for SendGrid API keys to understand access privileges and configure secure integrations.
Instructions
Get available permission scopes for API keys
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/misc.ts:5-14 (handler)The handler function that executes the get_scopes tool logic. It makes a GET request to the SendGrid API endpoint /v3/scopes and returns the available permission scopes as formatted JSON.
get_scopes: { config: { title: "Get Scopes", description: "Get available permission scopes for API keys", }, handler: async (): Promise<ToolResult> => { const result = await makeRequest("https://api.sendgrid.com/v3/scopes"); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, }, - src/tools/misc.ts:6-9 (schema)The tool configuration/schema defining its title and description. No input arguments are required; it takes no parameters.
config: { title: "Get Scopes", description: "Get available permission scopes for API keys", }, - src/index.ts:21-23 (registration)The registration loop where the get_scopes tool (along with all other tools) is registered with the MCP server. The tool name 'get_scopes' is derived from its object key.
for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); } - src/shared/api.ts:3-18 (helper)The helper makeRequest function called by the handler to perform the HTTP request to the SendGrid API. It attaches auth headers, checks for errors, and parses the JSON response.
export async function makeRequest(url: string, options: RequestInit = {}): Promise<any> { const response = await fetch(url, { headers: { ...getAuthHeaders(), ...options.headers, }, ...options, }); if (!response.ok) { const errorText = await response.text(); throw new Error(`SendGrid API error (${response.status}): ${errorText}`); } return response.json(); }