Skip to main content
Glama

vector_search

Enables vector similarity search in Turso databases by querying specific vectors within a table, returning results based on similarity for advanced data analysis.

Instructions

Performs vector similarity search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name (optional, uses context if not provided)
limitNoMaximum number of results (optional, default 10)
query_vectorYesQuery vector for similarity search
tableYesTable name
vector_columnYesColumn containing vectors

Implementation Reference

  • The async handler function that executes the vector similarity search using SQLite vector_distance and vector_from_json functions, constructs the query, executes it via database_client, and formats the results.
    async ({ table, vector_column, query_vector, limit = 10, database }) => {
    	try {
    		const database_name = resolve_database_name(database);
    		if (database) set_current_database(database);
    
    		// Construct a vector search query using SQLite's vector functions
    		const vector_string = query_vector.join(',');
    		const query = `
            SELECT *, vector_distance(${vector_column}, vector_from_json(?)) as distance
            FROM ${table}
            ORDER BY distance ASC
            LIMIT ?
          `;
    
    		const params = {
    			1: `[${vector_string}]`,
    			2: limit,
    		};
    
    		const result = await database_client.execute_query(
    			database_name,
    			query,
    			params,
    		);
    
    		const formatted_result = format_query_result(result);
    		return create_tool_response({
    			database: database_name,
    			table,
    			vector_column,
    			query_vector,
    			results: formatted_result,
    		});
    	} catch (error) {
    		return create_tool_error_response(error);
    	}
    },
  • Zod input schema defining parameters for the vector_search tool: table, vector_column, query_vector, optional limit and database.
    const VectorSearchSchema = z.object({
    	table: z.string().describe('Table name'),
    	vector_column: z.string().describe('Column containing vectors'),
    	query_vector: z.array(z.number()).describe('Query vector for similarity search'),
    	limit: z.number().optional().describe('Maximum number of results (optional, default 10)'),
    	database: z.string().optional().describe('Database name (optional, uses context if not provided)'),
    });
  • Registration of the vector_search tool with McpServer using name, description, VectorSearchSchema, and the handler function.
    server.tool(
    	{
    		name: 'vector_search',
    		description: 'Performs vector similarity search',
    		schema: VectorSearchSchema,
    	},
    	async ({ table, vector_column, query_vector, limit = 10, database }) => {
    		try {
    			const database_name = resolve_database_name(database);
    			if (database) set_current_database(database);
    
    			// Construct a vector search query using SQLite's vector functions
    			const vector_string = query_vector.join(',');
    			const query = `
             SELECT *, vector_distance(${vector_column}, vector_from_json(?)) as distance
             FROM ${table}
             ORDER BY distance ASC
             LIMIT ?
           `;
    
    			const params = {
    				1: `[${vector_string}]`,
    				2: limit,
    			};
    
    			const result = await database_client.execute_query(
    				database_name,
    				query,
    				params,
    			);
    
    			const formatted_result = format_query_result(result);
    			return create_tool_response({
    				database: database_name,
    				table,
    				vector_column,
    				query_vector,
    				results: formatted_result,
    			});
    		} catch (error) {
    			return create_tool_error_response(error);
    		}
    	},
    );
Behavior2/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 but offers minimal information. It states what the tool does ('performs vector similarity search') but doesn't describe behavioral traits like performance characteristics, error conditions, rate limits, authentication needs, or what the output looks like. For a tool with 5 parameters and no output schema, this leaves significant gaps in understanding how the tool behaves in practice.

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 extremely concise with just three words: 'Performs vector similarity search'. It's front-loaded with the core action and wastes no words. While it may be too brief for complete understanding, it earns maximum points for conciseness as every word contributes directly to stating the tool's purpose without redundancy or fluff.

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 tool's complexity (5 parameters, no annotations, no output schema), the description is inadequate. It doesn't explain what the tool returns, how results are structured, what similarity metric is used, or performance considerations. The agent must rely entirely on the input schema for parameter details and has no guidance on output format or behavioral characteristics, making this description incomplete for effective tool selection and invocation.

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 description adds no parameter-specific information beyond what's already in the schema (which has 100% coverage). All 5 parameters are documented in the input schema with descriptions, so the baseline score of 3 is appropriate. The description doesn't provide additional context about parameter relationships, constraints, or usage examples that would enhance understanding beyond the schema.

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

Purpose3/5

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

The description 'Performs vector similarity search' states the action but is vague about scope and resources. It specifies the verb 'performs' and the operation type 'vector similarity search', but doesn't clarify what resources it searches against (databases/tables) or how it differs from sibling tools like 'execute_query'. This provides basic purpose but lacks specificity and sibling differentiation.

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. There are no explicit statements about when/when-not to use it, no mention of prerequisites, and no comparison to sibling tools like 'execute_query' that might also handle queries. Usage context is entirely implied from the tool name and parameters, leaving the agent to infer appropriate scenarios.

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/spences10/mcp-turso-cloud'

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