Repository navigation
MCP Completion Issue #1065
Copy link
Copy link
Closed
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebugSomething isn't workingSomething isn't workingready for workEnough information for someone to start working onEnough information for someone to start working on
Description
Question
mcp = FastMCP("completion1",
instructions="A server that generates code from user prompts and JSON context. For all validation code generation requests from developers")
# Global store for extracted values
repo_cache = []
@mcp.tool()
async def long_task(files: list[str], ctx: Context) -> str:
"""Process a list of files asynchronously.
Args:
files (list[str]): _description_
ctx (Context): _description_
Returns:
str: _description_
"""
global repo_cache
repo_cache.clear() # reset
for i, file in enumerate(files):
ctx.info(f"Processing {file}")
with open(file, "r", encoding="utf-8") as f:
data = f.read()
# Just for illustration: suppose lines in file are repo names
lines = data.splitlines()
repo_cache.extend(lines)
await ctx.report_progress(i + 1, len(files))
ctx.info(f"Cached repos: {repo_cache}")
return "Processing complete"
@mcp.completion()
async def free_text_completion(argument: CompletionArgument) -> Completion:
"""Handle free text completion requests.
Args:
argument (CompletionArgument): The argument containing the user's input.
Returns:
Completion: A completion object containing suggestions based on the user's input.
"""
# Use the global repo_cache to provide suggestions
global repo_cache
suggestions = repo_cache or ["code_genrator", "some_other_repo"]
matches = [r for r in suggestions if r.startswith(argument.value)]
return Completion(values=matches)
if __name__ == "__main__":
mcp.run(transport="stdio")
we have three queries as follows-
I have implemented a context loader & a completion endpoint as above I'm using mcp tools & it's completion endpoint with GitHub copilot in VS code.
Hear are my queries-
- How can I get my recommendation using completion endpoint in completion1.
- Where I will be getting the recommendation in VS code file editor or in GitHub copilot while MCP is connected & is running.
- What are the additional implementations I can add here to make the MCP'c workflow better.
My mcp for now is loading the context & further generation are happening through it one I have sent a query from GitHub copilot.
Please help with the queries I have written above.
Reacted by Amit Tiwari, Nilesh Malode and akshada-pawar22
Reacted by naitikkachhara9
Metadata
Metadata
Assignees
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebugSomething isn't workingSomething isn't workingready for workEnough information for someone to start working onEnough information for someone to start working on
Activity
Amitt1412 commentedon Jul 1, 2025
I too have faced the same issues when I was working with the MCPs implementation for my environment. I struggled finding a proper implementation of MCP completion with GitHub copilot in VS Code.
akshada-pawar22 commentedon Jul 1, 2025
I’m facing the same issue
[-]MCP Completion Endpoint Issue[/-][+]MCP Completion Issue[/+]maxisbey commentedon Jul 24, 2026
MCP completions apply to exactly two things — the arguments of a prompt and the parameters of a resource template — and the client sends
completion/completewhile its user is filling one of those in (see the Completions guide). A server that only registers a tool never receives that request, sofree_text_completionis never called: tool arguments are chosen by the model, not through completions. To answer (1), give the handler something to complete — e.g. a prompt with arepoargument — and use the full(ref, argument, context)handler signature; the example below adapts your repo cache and drives it with the in-memory client (v2 API:FastMCPis nowMCPServer). For (2), where and whether those suggestions appear is the client's UI decision (VS Code / Copilot), not something this SDK controls. For (3), to get the cached repo list in front of the model, expose it as a resource or return it from a tool — completions are for a human filling in a form.Example
Closing this as part of a wider backlog cleanup around the v2 release. Feel free to reopen if this is still relevant.
AI Disclaimer