Skip to main content
Glama
ssm82

Full VK MCP

by ssm82

vk_friends_search

Search VK friends by name or other criteria. Retrieve matching profiles with customizable fields, limits, and pagination.

Instructions

Returns a list of friends matching the search criteria.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoUser ID.
qNoSearch query string (e.g., 'Vasya Babich').
fieldsNoProfile fields to return. Sample values: 'nickname', 'screen_name', 'sex', 'bdate' (birthdate), 'city', 'country', 'timezone', 'photo', 'photo_medium', 'photo_big', 'has_mobile', 'rate', 'contacts', 'education', 'online',
name_caseNoCase for declension of user name and surname: 'nom' - nominative (default), 'gen' - genitive , 'dat' - dative, 'acc' - accusative , 'ins' - instrumental , 'abl' - prepositional
offsetNoOffset needed to return a specific subset of friends.
countNoNumber of friends to return.

Implementation Reference

  • buildTools maps each VK API method to an MCP tool. The tool name is derived from the method name via getToolName(), which converts 'friends.search' -> 'vk_friends_search'.
    export function buildTools(methods) {
      return methods.map(method => ({
        name: getToolName(method.name),
        description: cleanDescription(method.description, method.name),
        inputSchema: buildInputSchema(method.parameters),
      }));
  • getToolName converts VK API method names like 'friends.search' into MCP tool names like 'vk_friends_search' by replacing dots with underscores and lowercasing.
    function getToolName(methodName) {
      return `vk_${methodName
        .replace(/\./g, '_')
        .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
        .toLowerCase()}`;
    }
  • The 'friends.search' VK API method is included in the 'search' profile, which will be registered as tool 'vk_friends_search'.
    'friends.search',
  • buildHandler creates the generic handler that dispatches tool calls. When 'vk_friends_search' is called, it looks up the corresponding VK method name 'friends.search' and calls vkClient.call('friends.search', args).
    export function buildHandler(methods, vkClient) {
      const methodMap = new Map();
    
      for (const method of methods) {
        methodMap.set(getToolName(method.name), method.name);
      }
    
      return async function handler(params) {
        const { name, arguments: args } = params;
    
        if (!methodMap.has(name)) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({ error: `Unknown tool: ${name}` }, null, 2),
              },
            ],
            isError: true,
          };
        }
    
        const vkMethod = methodMap.get(name);
    
        try {
          const result = await vkClient.call(vkMethod, args || {});
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({ error: error.message }, null, 2),
              },
            ],
            isError: true,
          };
        }
      };
  • VKClient.call is the actual HTTP caller that executes the VK API method (e.g., 'friends.search') against the VK API endpoint.
    async call(method, params = {}, { timeoutMs = 30000 } = {}) {
      const normalized = {};
      for (const [k, v] of Object.entries(params)) {
        if (v === undefined || v === null) continue;
        if (typeof v === 'boolean') {
          normalized[k] = v ? '1' : '0';
        } else if (Array.isArray(v)) {
          normalized[k] = v.join(',');
        } else {
          normalized[k] = String(v);
        }
      }
    
      const body = new URLSearchParams({
        ...normalized,
        access_token: this.accessToken,
        v: this.apiVersion,
      });
    
      const controller = new AbortController();
      const timeout = setTimeout(() => controller.abort(), timeoutMs);
    
      try {
        const response = await fetch(`${this.baseUrl}/${method}`, {
          method: 'POST',
          headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
          body: body.toString(),
          signal: controller.signal,
        });
    
        const text = await response.text();
    
        if (!response.ok) {
          const safeText = text.replace(this.accessToken, '***');
          throw new Error(`VK HTTP Error ${response.status}: ${safeText}`);
        }
    
        let data;
        try {
          data = JSON.parse(text);
        } catch {
          const safeText = text.replace(this.accessToken, '***');
          throw new Error(`VK API returned non-JSON response: ${safeText}`);
        }
    
        if (data.error) {
          const code = data.error.error_code;
          const msg = data.error.error_msg;
          throw new Error(`VK API Error ${code}: ${msg}`);
        }
    
        return data.response;
      } catch (err) {
        if (err.name === 'AbortError') {
          throw new Error(`VK API timeout after ${timeoutMs}ms for method ${method}`);
        }
        throw err;
      } finally {
        clearTimeout(timeout);
      }
    }
Behavior2/5

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

No annotations provided. Description is minimal and does not disclose behavioral traits like pagination, rate limits, or return format. It only states the basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, very concise. It front-loads the purpose without extra words.

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

Completeness1/5

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

Given 6 parameters, no output schema, and no annotations, the description is severely incomplete. It does not explain return structure, pagination behavior, or how parameters affect results.

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 parameters are well-documented in schema. Description adds no additional meaning beyond that, meeting baseline expectation.

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 returns friends matching search criteria. It uses a specific verb and resource, and distinguishes itself from sibling tools like vk_friends_get which returns all friends.

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?

No guidance on when to use this vs alternatives (e.g., vk_friends_get, vk_friends_search). No mention of prerequisites or context.

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/ssm82/full-vk-mcp'

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