---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/work-with-mcp.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/work-with-mcp.md
  - href: en/sourcecraft/operations/work-with-mcp.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: Working with a SourceCraft MCP server
description: How to work with SourceCraft resources via an MCP server using an AI agent.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


<!-- source: en/_includes/code-assistant/work-with-mcp.md -->
# Working with a SourceCraft MCP server

[SourceCraft MCP](https://sourcecraft.dev/portal/docs/en/code-assistant/operations/agent/mcp/recommended-mcp-servers.md) enables AI agents to work with SourceCraft entities, e.g., search for and complete [issues](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#issues), create [pull requests](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr), and manage other resources on the platform.

In this guide, we will use Code Assistant and SourceCraft MCP to find an issue in a repository, make the necessary changes, push them to the repository, and then close the issue.

In the example, the MCP server is managed using the Code Assistant plugin, but you can [use](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/connect-to-mcp.md#universal-installation) any other agent that supports MCP.

<!-- source: en/_includes/code-assistant/recommended-mcp-servers.md -->
{% note info %}

You can view the list of Yandex Cloud and SourceCraft MCP servers, as well as recommended MCP servers, in [SourceCraft and Yandex Cloud MCP servers](https://sourcecraft.dev/portal/docs/en/code-assistant/operations/agent/mcp/recommended-mcp-servers.md).

{% endnote %}
<!-- endsource: en/_includes/code-assistant/recommended-mcp-servers.md -->

## Set up your environment {#prepare}

For this tutorial, you will need the following tools:

* [Visual Studio Code](https://code.visualstudio.com/download)
* [Code Assistant plugin for Visual Studio Code](https://sourcecraft.dev/portal/docs/en/code-assistant/index.md)
* [Git](https://git-scm.com/downloads)
* [Python](https://www.python.org/downloads/)

## Check the MCP connection {#check-mcp}

If the repository resides in SourceCraft, Code Assistant automatically connects the SourceCraft MCP. No PAT is required.

1. In VS Code, click the plugin icon ![image](../../_assets/code-assistant/vsc-icon-small.svg) in the left-hand panel.
1. In the panel that opens, select ![image](../../_assets/console-icons/gear.svg) **Settings**.
1. Go to **MCP servers**.
1. Make sure the SourceCraft server is active.

## Prepare a repository {#create-repo}

1. [Create an empty repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/repo-create.md#create-empty), e.g., `mcp-test`.
1. [Add](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/add-file-repo.md) to the created repository a file named `hello.py` with the following contents:

   ```python
   print("Hello, World")
   ```

1. [Create](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/issue-create.md) an issue titled _Add a version in Russian_ with the following description:

   ```text
   Add an alternative option in Russian to the hello.py file. The user will select the language when running the file.
   ```

## Send your requests to the chat {#send-requests}

In this example, we used the `mcp-test` public repository in the [organization](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#org) named `orgname`. Use your own names for requests to Code Assistant.

The results may vary depending on the model and selected behavior mode.

1. In VSCode, click the plugin icon ![image](../../_assets/code-assistant/vsc-icon-small.svg) in the left-hand panel.

1. In the chat that opens, ask Code Assistant to display a list of issues:

   ```text
   Show a list of issues in the mcp-test repository of the organization named orgname.
   ```

   The assistant will use the `ListRepositoryIssues` tool to display the list of issues. Depending on your plugin settings, you may need to approve the request.

1. Clone the repository using Code Assistant:

   ```text
   Now clone the repository.
   ```

   The assistant will get the clone link using the `GetRepository` tool and then run the `git clone` command.

1. Ask Code Assistant to complete the issue in a new repository branch:

   ```text
   Create a new repository branch and complete the previously mentioned issue of adding a version in Russian.
   ```

   The assistant will edit the `hello.py` file and add a commit with the changes using `git`.

1. If Code Assistant did not test the edited code in the previous step, ask it to do so:

   ```text
   Test the code.
   ```

   The assistant will test the updated code and display the test results.

1. Create a new pull request in the repository using the assistant:

   ```text
   Create a new pull request from the branch in the repository and link it to the previously mentioned issue.
   ```

   The assistant will get the issue information in the repository using the `GetRepository` and `GetIssue` tools, push the changes to the remote repository via `git`, create a pull request using `CreatePullRequest`, and link it to the original issue via `AddLinkedPRs`.

1. Find the new pull request in the [SourceCraft interface](https://sourcecraft.dev), review it, and [merge it](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-work.md#merge) into the main branch.

1. Ask Code Assistant to write a comment and close the issue:

   ```text
   In the issue, leave a comment stating the issue is complete and then close it.
   ```

   The assistant will open the issue using the `GetIssue` tool and then update it using the `CreateIssueComment` and `UpdateIssue` tools.

   To review the Code Assistant work, open the repository in a browser and make sure that the changes have been made and the task is closed.

{% note tip %}

This tutorial describes step-by-step commands for Code Assistant when working with SourceCraft MCP for more granular control over the agent's actions.

You can also describe all actions for Code Assistant to perform in a single general command and adjust the assistant as it proceeds.

{% endnote %}
<!-- endsource: en/_includes/code-assistant/work-with-mcp.md -->

#### Useful links {#see-also}

* [SourceCraft and Yandex Cloud MCP servers](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/connect-to-mcp.md)
* [MCP overview](https://sourcecraft.dev/portal/docs/en/code-assistant/operations/agent/mcp/overview.md)
