Skip to main content
Glama

Setup API Key

setup_api_key

Authenticate with StacksFinder to generate an API key for accessing Pro features, including tech stack recommendations and scoring tools.

Instructions

Authenticates with your StacksFinder account and creates an API key. Requires Pro or Team tier. The key is returned once and should be saved securely.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYesYour StacksFinder account email
passwordYesYour StacksFinder account password
keyNameNoOptional name for the API key

Implementation Reference

  • The executeSetupApiKey function handles the tool execution: authenticates with StacksFinder API using email/password, creates a new API key, handles errors with specific messages, and returns formatted instructions including the key and setup commands.
    export async function executeSetupApiKey(
    	input: SetupApiKeyInput
    ): Promise<{ text: string; isError?: boolean; apiKey?: string }> {
    	const config = getConfig();
    	const { email, password, keyName } = input;
    
    	debug('Setting up API key for', email);
    
    	try {
    		const response = await fetch(`${config.apiUrl}/api/v1/mcp/setup`, {
    			method: 'POST',
    			headers: {
    				'Content-Type': 'application/json'
    			},
    			body: JSON.stringify({
    				email,
    				password,
    				keyName: keyName || 'MCP Auto-generated'
    			})
    		});
    
    		const data = (await response.json()) as SetupApiResponse;
    
    		if (!response.ok || !data.success) {
    			let errorMessage = data.message || data.error || 'Failed to create API key';
    
    			// Add helpful context for common errors
    			if (data.error === 'TIER_REQUIRED') {
    				errorMessage = `Pro or Team tier required. Upgrade at ${config.apiUrl}/pricing`;
    			} else if (data.error === 'LIMIT_EXCEEDED') {
    				errorMessage = `API key limit reached. Manage keys at ${config.apiUrl}/account/developer/api-keys`;
    			} else if (data.error === 'INVALID_CREDENTIALS') {
    				errorMessage = 'Invalid email or password. Please check your credentials.';
    			}
    
    			return {
    				text: `**Error**: ${errorMessage}`,
    				isError: true
    			};
    		}
    
    		info('API key created successfully');
    
    		// Return the key with instructions
    		const text = `## API Key Created Successfully
    
    **Key**: \`${data.apiKey}\`
    **Key ID**: ${data.keyId}
    **Prefix**: ${data.prefix}
    
    **IMPORTANT**: Save this key now - it cannot be retrieved again!
    
    ### Configure in Claude Code
    
    Run this command to add the key:
    
    \`\`\`bash
    claude mcp add-json stacksfinder '{"command": "npx", "args": ["-y", "@stacksfinder/mcp-server"], "env": {"STACKSFINDER_API_KEY": "${data.apiKey}"}}'
    \`\`\`
    
    Or set the environment variable:
    
    \`\`\`bash
    export STACKSFINDER_API_KEY="${data.apiKey}"
    \`\`\`
    
    ### Manage Your Keys
    
    View and manage keys at: ${config.apiUrl}/account/developer/api-keys`;
    
    		return { text, apiKey: data.apiKey };
    	} catch (err) {
    		if (err instanceof McpError) {
    			return { text: err.toResponseText(), isError: true };
    		}
    
    		const errorMessage = err instanceof Error ? err.message : 'Failed to setup API key';
    		return {
    			text: `**Error**: ${errorMessage}\n\nMake sure you can reach ${config.apiUrl}`,
    			isError: true
    		};
    	}
    }
  • Zod schema defining the input parameters for the setup_api_key tool: email (required, validated as email), password (required, non-empty), keyName (optional, max 100 chars).
    /**
     * Input schema for setup_api_key tool.
     */
    export const SetupApiKeyInputSchema = z.object({
    	email: z.string().email().describe('Your StacksFinder account email'),
    	password: z.string().min(1).describe('Your StacksFinder account password'),
    	keyName: z.string().max(100).optional().describe('Optional name for the API key')
    });
  • src/server.ts:302-328 (registration)
    Registers the 'setup_api_key' tool on the MCP server using server.registerTool, providing title, description from toolDefinition, inputSchema (mirroring the Zod schema), annotations, and an async handler that parses input with SetupApiKeyInputSchema and calls executeSetupApiKey.
    // Register setup_api_key tool (API-based, no auth required)
    server.registerTool(
    	setupApiKeyToolDefinition.name,
    	{
    		title: 'Setup API Key',
    		description: setupApiKeyToolDefinition.description,
    		inputSchema: {
    			email: z.string().email().describe('Your StacksFinder account email'),
    			password: z.string().min(1).describe('Your StacksFinder account password'),
    			keyName: z.string().max(100).optional().describe('Optional name for the API key')
    		},
    		annotations: {
    			readOnlyHint: false,
    			destructiveHint: false,
    			openWorldHint: false
    		}
    	},
    	async (args) => {
    		debug('setup_api_key called', args.email);
    		const input = SetupApiKeyInputSchema.parse(args);
    		const { text, isError } = await executeSetupApiKey(input);
    		return {
    			content: [{ type: 'text', text }],
    			isError
    		};
    	}
    );
  • Tool metadata definition including the exact name 'setup_api_key' and detailed description used during registration.
    /**
     * Tool definition for setup_api_key.
     */
    export const setupApiKeyToolDefinition = {
    	name: 'setup_api_key',
    	description:
    		'Authenticates with your StacksFinder account and creates an API key. Requires Pro or Team tier. The key is returned once and should be saved securely.'
    };
Behavior4/5

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

Annotations already indicate this is a non-destructive write operation (readOnlyHint: false, destructiveHint: false). The description adds valuable behavioral context beyond annotations: it discloses that the key is returned only once and should be saved securely, which are critical implementation details not captured in structured fields.

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 front-loaded with the core purpose and efficiently conveys essential information in just two sentences. Every sentence earns its place: the first explains the action and prerequisites, while the second provides critical behavioral guidance about key security.

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?

For a tool that creates credentials with no output schema, the description is reasonably complete. It covers the purpose, prerequisites, and key behavioral aspects (one-time return, security). However, it could mention what happens on failure (e.g., invalid credentials) or the format of the returned key, which would enhance completeness.

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?

Schema description coverage is 100%, so the schema fully documents all three parameters (email, password, keyName). The description doesn't add any parameter-specific semantics beyond what the schema provides, such as explaining the format of keyName or authentication requirements. Baseline 3 is appropriate when the schema handles parameter documentation.

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 ('Authenticates... and creates an API key') and resource ('your StacksFinder account'), distinguishing it from sibling tools like list_api_keys or revoke_api_key. It goes beyond just restating the name/title by explaining the authentication and key creation process.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Requires Pro or Team tier'), which helps differentiate it from alternatives. However, it doesn't explicitly state when NOT to use it (e.g., if you already have an API key) or name specific alternatives like list_api_keys for checking existing keys.

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/hoklims/stacksfinder-mcp'

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