Skip to main content
Glama
spences10

MCP Svelte Docs Server

Lookup Svelte 5 & SvelteKit definitions from TypeScript declarations. Covers all runes ($state, $derived, $props, $effect), features (snippets, onclick, component-events), and patterns. Supports syntax/quick/full format for varying detail levels.

svelte_definition

Look up Svelte 5 and SvelteKit definitions from TypeScript declarations, covering runes like $state and $derived, features, and patterns with syntax, quick, or full detail levels.

Instructions

Lookup Svelte 5 & SvelteKit definitions from TypeScript declarations. Covers all runes ($state, $derived, $props, $effect), features (snippets, onclick, component-events), and patterns. Supports syntax/quick/full format for varying detail levels.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYesSvelte 5 identifier: $state, $derived, $props, $effect, snippets, onclick, component-events
formatNoOutput detail level: "syntax" (signature only), "quick" (with example), "full" (complete docs)full

Implementation Reference

  • The main execution logic for the svelte_definition tool: validates input, retrieves definition from database, formats output based on 'syntax/quick/full', handles errors with suggestions
    async function definition_handler(args: any) {
    	try {
    		// Validate input
    		const { identifier, format = 'full' } = v.parse(
    			DefinitionSchema,
    			args,
    		);
    
    		// Find the definition
    		const definition = get_definition_by_identifier(identifier);
    
    		if (!definition) {
    			throw create_definition_error(identifier, definitions);
    		}
    
    		// Validate that definition content exists
    		if (
    			!definition.content ||
    			definition.content.trim().length === 0
    		) {
    			throw new Error(
    				`Definition for '${identifier}' exists but appears to be empty. Please try again later or contact support.`,
    			);
    		}
    
    		// Format the content based on requested format
    		const formatted_content = format_definition_content(
    			definition.content,
    			format,
    		);
    
    		// Add format info for context
    		let response_content = formatted_content;
    		if (format === 'syntax') {
    			response_content += `\n\n*Use format="quick" or format="full" for more details.*`;
    		} else if (format === 'quick') {
    			response_content += `\n\n*Use format="full" for complete documentation.*`;
    		}
    
    		return {
    			content: [
    				{
    					type: 'text' as const,
    					text: response_content,
    				},
    			],
    		};
    	} catch (error) {
    		// Re-throw with additional context for debugging
    		const errorMessage =
    			error instanceof Error
    				? error.message
    				: 'Unknown error occurred';
    		throw new Error(`Error in svelte_definition: ${errorMessage}`);
    	}
    }
  • Valibot input schema defining parameters: identifier (required string) and format (optional: syntax/quick/full)
    const DefinitionSchema = v.object({
    	identifier: v.pipe(
    		v.string(),
    		v.minLength(1),
    		v.description(
    			'Svelte 5 identifier: $state, $derived, $props, $effect, snippets, onclick, component-events',
    		),
    	),
    	format: v.pipe(
    		v.optional(v.picklist(['syntax', 'quick', 'full']), 'full'),
    		v.description(
    			'Output detail level: "syntax" (signature only), "quick" (with example), "full" (complete docs)',
    		),
    	),
    });
  • Tool registration call within register_definition_tools function, specifying name, description, schema, and handler
    server.tool<typeof DefinitionSchema>(
    	{
    		name: 'svelte_definition',
    		description:
    			'Lookup Svelte 5 & SvelteKit definitions from TypeScript declarations. Covers all runes ($state, $derived, $props, $effect), features (snippets, onclick, component-events), and patterns. Supports syntax/quick/full format for varying detail levels.',
    		schema: DefinitionSchema,
    	},
    	definition_handler,
    );
  • src/index.ts:64-65 (registration)
    Top-level call to register the svelte_definition tool during server initialization
    // Register definition tools (single svelte_definition tool)
    register_definition_tools(this.server);
  • Helper function to format definition content based on requested detail level (syntax/quick/full)
    function format_definition_content(
    	content: string,
    	format: FormatType,
    ): string {
    	switch (format) {
    		case 'syntax':
    			return extract_syntax_only(content);
    		case 'quick':
    			return extract_definition_and_example(content);
    		case 'full':
    		default:
    			return content;
    	}
    }
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 describes the tool's function and output formats but does not cover critical aspects such as whether this is a read-only operation, potential rate limits, error handling, or authentication requirements. For a lookup tool with zero annotation coverage, this is a significant gap.

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, with two sentences that efficiently convey the tool's scope and functionality. Every sentence adds value without redundancy, making it easy for an agent to parse quickly.

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?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and parameters but lacks behavioral details and usage guidelines. Without an output schema, it does not explain return values, which is a gap, but the description compensates somewhat by mentioning output formats.

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 schema description coverage is 100%, with clear descriptions for both parameters. The description adds minimal value beyond the schema by mentioning the coverage of runes and features, which relates to the 'identifier' parameter, but does not provide additional syntax or usage details. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tautological: description restates name/title.

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 mentions what the tool covers and the output formats, but does not specify use cases, prerequisites, or exclusions. This leaves the agent without context for optimal tool selection.

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/spences10/mcp-svelte-docs'

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