MoonshotAI / MoonshotAI/kimi-code
Headless mode: support per-invocation system prompt append and MCP config
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
What feature would you like to see?
We are integrating Kimi Code as an external headless agent runtime. kimi -p --output-format stream-json is already a good fit for this use case:
- one invocation has a clear turn boundary;
- print mode uses automatic permissions;
stream-jsonis machine-readable;--skills-diralready works;- the final
session.resume_hintexposes a session id that can be passed back through--session <id>.
Two per-invocation host inputs are still missing:
-
Append-only host system instructions
Allow a host to append instructions to Kimi's normal effective system prompt without replacing the native profile and without writing an
AGENTS.mdfile. -
Explicit MCP configuration for this invocation
Allow a host to provide the MCP servers for a
-pinvocation, with an opt-in replace mode that ignores MCP servers discovered from the user's, project's, or plugin configuration.
The exact option names are only illustrative:
kimi -p "..." \
--output-format stream-json \
--append-system-prompt-file /path/to/host-role.md \
--mcp-config /path/to/mcp.json \
--mcp-config-mode replace
Expected semantics:
- The appended prompt is applied after Kimi's normal profile/project instructions for both new and
--session <id>resumed invocations. - It is scoped to the invocation, is not persisted as project/user configuration, and does not write into the workspace or Kimi home.
- In MCP
replacemode, the supplied file is the complete external MCP server set; an empty set means no external MCP servers. - Without these options, current behavior is unchanged.
This keeps host-owned role instructions separate from repository instructions and lets a host supply dynamic, session-specific MCP endpoints while continuing to use the user's normal Kimi home, login, model configuration, and session storage.
Additional information
Current main already forwards --skills-dir into print mode's harness, so no skill-directory change is requested here:
The underlying v1 session creation/resume path already has caller-supplied MCP inputs, but it merges them with discovered native MCP configuration:
The public print CLI currently does not expose either the host prompt append or the caller MCP input.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the print-mode forwarding in apps/kimi-code/src/cli/run-prompt.ts and prompt handling in apps/kimi-code/src/cli/prompt-render.ts. Then trace the new and resumed session MCP resolution in packages/agent-core/src/rpc/core-impl.ts. Done means per-invocation prompt append and MCP configuration work for new and resumed print sessions, including replace mode, without changing behavior when the options are absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100