[Feature Request] Print mode support MCP servers

Status Fixed / completed
Maintainer reply ✓ Yes — ashwin-ant
Activity 7 comments · opened Mar 24, 2025 · closed Mar 25, 2025
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

Would be great to have MCP support in print mode. I've tried several various ways to get Claude code with print/non interactive mode (-p) to use an MCP but it just ignores it. I also tried included the tool used by the MCP server in the allowed tools list but did not have any luck.

The same command in interactive mode successfully calls the MCP

View original on GitHub ↗

7 Comments

ashwin-ant collaborator · 1 year ago

This is something we support. Can you share more details about the command you're providing? Also any details about the MCP server configuration if possible (claude mcp get <serverName>).

mjrussell · 1 year ago

Yeah! Let me try to provide some more info:

> claude --version
0.2.53 (Claude Code)
❯ claude mcp get linear
linear:
  Scope: Local (private to you in this project)
  Type: stdio
  Command: npx
  Args: -y @ibraheem4/linear-mcp
  Environment:
    LINEAR_API_KEY=<myapikey>

Inside the claude interactive, same dir:

> claude
> fetch details for  linear ticket <myticketID>
> linear:search_issues (MCP)(query: "<myticketID>")

And then it asks me if I want to proceed or allow-list it for the directory.

With print mode:

❯ claude -p "fetch details for  linear ticket <myticketID>"                                      
I'll need you to share the Linear ticket URL directly or provide another way to access the <myticketID> details. The WebFetchTool can only access URLs that you explicitly share.
> ❯ claude -p "fetch details for  linear ticket <myticketID> using linear MCP" --allowedTools "linear:*"
I'll need to use the Linear MCP tool to fetch details for <myticketID>, but that tool doesn't appear to be available in this environment. Would you like me to try another approach to find information about this ticket?
>❯ claude -p "fetch details for  linear ticket <myticketID> using linear MCP" --allowedTools "linear"  
I don't have access to a Linear MCP tool. You'll need to use the Linear CLI directly or another tool that integrates with Linear to fetch ticket <myticketID>
ashwin-ant collaborator · 1 year ago

This is fixed in 0.2.54!

mjrussell · 1 year ago

NIce! Can you provide an example for what the allowedTools string should be?

ashwin-ant collaborator · 1 year ago

MCP server tools get provided to the model as mcp__${serverName}__${toolName}. So you'd probably want:

--allowedTools "mcp__linear__get_issue"

or if you wanted to allow multiple, you could do something like

--allowedTools "mcp__linear__get_issue,mcp__linear__list_issues"

We'll be making it a bit easier to allow everything from a single server soon, as well as adding this to the public-facing docs.

mjrussell · 1 year ago

Ah works great, thank you!

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.