Skip to main content
Glama
bulatko

vk-mcp-server

vk_wall_post

Publish posts to VKontakte walls using the VK API. Create text content for user or community profiles with customizable ownership settings.

Instructions

Publish a new post on a wall

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
owner_idNoWall owner ID
messageYesPost text content
from_groupNoPost on behalf of community

Implementation Reference

  • The vk_wall_post tool handler that processes tool calls, extracts arguments, and calls vk.wallPost() with owner_id, message, and from_group parameters
    case 'vk_wall_post':
      result = await vk.wallPost({
        owner_id: args.owner_id,
        message: args.message,
        from_group: args.from_group ? 1 : 0,
      });
      break;
  • Tool schema definition for vk_wall_post with name, description, inputSchema defining owner_id, message (required), and from_group parameters
    {
      name: 'vk_wall_post',
      description: 'Publish a new post on a wall',
      inputSchema: {
        type: 'object',
        properties: {
          owner_id: { type: 'number', description: 'Wall owner ID' },
          message: { type: 'string', description: 'Post text content' },
          from_group: { type: 'boolean', description: 'Post on behalf of community' },
        },
        required: ['message'],
      },
    },
  • VKClient.wallPost method that wraps the VK API wall.post call
    wallPost(params) { return this.call('wall.post', params); }
  • VKClient.call method that executes VK API requests with authentication and error handling
    async call(method, params = {}) {
      const body = new URLSearchParams({
        ...params,
        access_token: this.accessToken,
        v: this.apiVersion,
      });
    
      const response = await fetch(`${VK_API_BASE}/${method}`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        body: body.toString(),
      });
    
      const data = await response.json();
    
      if (data.error) {
        throw new Error(`VK API Error ${data.error.error_code}: ${data.error.error_msg}`);
      }
    
      return data.response;
    }
  • The handleToolCall function that routes tool requests to appropriate VK API methods based on tool name
    async function handleToolCall(name, args) {
      try {
        let result;
    
        switch (name) {
          case 'vk_users_get':
            result = await vk.usersGet({
              user_ids: args.user_ids,
              fields: args.fields || 'photo_200,online,status',
            });
            break;
    
          case 'vk_wall_get':
            result = await vk.wallGet({
              owner_id: args.owner_id,
              domain: args.domain,
              count: args.count || 20,
              offset: args.offset,
            });
            break;
    
          case 'vk_wall_post':
            result = await vk.wallPost({
              owner_id: args.owner_id,
              message: args.message,
              from_group: args.from_group ? 1 : 0,
            });
            break;
    
          case 'vk_wall_create_comment':
            result = await vk.wallCreateComment({
              owner_id: args.owner_id,
              post_id: args.post_id,
              message: args.message,
            });
            break;
    
          case 'vk_groups_get':
            result = await vk.groupsGet({
              user_id: args.user_id,
              filter: args.filter,
              fields: args.fields || 'description,members_count',
              count: args.count || 100,
            });
            break;
    
          case 'vk_groups_get_by_id':
            result = await vk.groupsGetById({
              group_ids: args.group_ids,
              fields: args.fields || 'description,members_count',
            });
            break;
    
          case 'vk_friends_get':
            result = await vk.friendsGet({
              user_id: args.user_id,
              order: args.order,
              fields: args.fields || 'photo_200,online',
              count: args.count || 100,
            });
            break;
    
          case 'vk_newsfeed_get':
            result = await vk.newsfeedGet({
              filters: args.filters || 'post',
              count: args.count || 20,
              start_from: args.start_from,
            });
            break;
    
          case 'vk_stats_get':
            result = await vk.statsGet({
              group_id: args.group_id,
              interval: args.interval || 'day',
              intervals_count: args.intervals_count || 7,
            });
            break;
    
          case 'vk_photos_get':
            result = await vk.photosGet({
              owner_id: args.owner_id,
              album_id: args.album_id || 'wall',
              count: args.count || 50,
            });
            break;
    
          default:
            throw new Error(`Unknown tool: ${name}`);
        }
    
        return JSON.stringify(result, null, 2);
      } catch (error) {
        return JSON.stringify({ error: error.message });
      }
    }

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/bulatko/vk-mcp-server'

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