Skip to content

[Bug] Prompt argument names are not parsed #246

@Eckii24

Description

@Eckii24

Background

I have configured a mcp server to manage prompts, even some with arguments.
mcphub.nvim was in the past able to nicely parse the arguments with their names.

Issue

Currently, I can only see a black box to insert the arguments.
In normal mode I even see the keymap hints. I can also insert something and these values are actually considered as arguments. But the UX is currently not nice, because I can not see, what I'm inserting:

Screen.Recording.2025-09-12.at.22.18.48.mov

Do you have any idea, why this is the case?

Used minimal configuration:

(I have also added a prompt using the native servers to make it easier to test)

---@diagnostic disable: missing-fields

--[[
NOTE: Set the config path to enable the copilot adapter to work.
It will search the following paths for a token:
  - "$CODECOMPANION_TOKEN_PATH/github-copilot/hosts.json"
  - "$CODECOMPANION_TOKEN_PATH/github-copilot/apps.json"
--]]
vim.env["CODECOMPANION_TOKEN_PATH"] = vim.fn.expand("~/.config")

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

-- Your CodeCompanion setup
local plugins = {
	{
		"ravitemer/mcphub.nvim",
		dependencies = {
			"nvim-lua/plenary.nvim", -- Required for Job and HTTP requests
		},
		cmd = "MCPHub",
		build = "npm install -g mcp-hub@latest", -- Installs required mcp-hub npm module"ravitemer/mcphub.nvim",
		config = function()
			require("mcphub").setup({
				native_servers = {
					example = {
						name = "example",
						display_name = "Example Server",
						capabilities = {
							prompts = {
								{
									name = "chat",
									description = "Start a friendly chat",

									-- Optional arguments
									arguments = {
										{
											name = "topic",
											description = "What to chat about",
											required = true,
										},
									},

									-- Prompt handler
									handler = function(req, res)
										return res
											-- Set behavior
											:system()
											:text(
												"You are a friendly chat assistant.\n" .. "Topic: " .. req.params.topic
											)
											-- Add example interaction
											:user()
											:text("Tell me about " .. req.params.topic)
											:llm()
											:text("I'd love to discuss " .. req.params.topic)
											-- Send prompt
											:send()
									end,
								},
							},
						},
					},
				},
			})
		end,
	},
	{
		"olimorris/codecompanion.nvim",
		dependencies = {
			-- needed to install additional parsers
			{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
			{ "nvim-lua/plenary.nvim" },
			-- Test with blink.cmp (delete if not required)
			{ "ravitemer/mcphub.nvim" },
			{
				"saghen/blink.cmp",
				lazy = false,
				version = "*",
				opts = {
					keymap = {
						preset = "enter",
						["<S-Tab>"] = { "select_prev", "fallback" },
						["<Tab>"] = { "select_next", "fallback" },
					},
					cmdline = { sources = { "cmdline" } },
					sources = {
						default = { "lsp", "path", "buffer", "codecompanion" },
					},
				},
			},
			-- Test with nvim-cmp
			-- { "hrsh7th/nvim-cmp" },
		},
		opts = {
			--Refer to: https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/config.lua
			strategies = {
				--NOTE: Change the adapter as required
				chat = { adapter = "copilot" },
				inline = { adapter = "copilot" },
			},
			opts = {
				log_level = "DEBUG",
			},
			extensions = {
				mcphub = {
					callback = "mcphub.extensions.codecompanion",
					opts = {
						-- MCP Tools
						make_tools = true, -- Make individual tools (@server__tool) and server groups (@server) from MCP servers
						show_server_tools_in_chat = true, -- Show individual tools in chat completion (when make_tools=true)
						add_mcp_prefix_to_tool_names = false, -- Add mcp__ prefix (e.g `@mcp__github`, `@mcp__neovim__list_issues`)
						show_result_in_chat = true, -- Show tool results directly in chat buffer
						format_tool = nil, -- function(tool_name:string, tool: CodeCompanion.Agent.Tool) : string Function to format tool names to show in the chat buffer
						-- MCP Resources
						make_vars = true, -- Convert MCP resources to #variables for prompts
						-- MCP Prompts
						make_slash_commands = true, -- Add MCP prompts as /slash commands
					},
				},
			},
		},
	},
}

require("lazy.minit").repro({ spec = plugins })

-- Setup Tree-sitter
local ts_status, treesitter = pcall(require, "nvim-treesitter.configs")
if ts_status then
	treesitter.setup({
		ensure_installed = { "lua", "markdown", "markdown_inline", "yaml", "diff" },
		highlight = { enable = true },
	})
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions