• Feed
  • Explore
  • Ranking
/

    [신상공부]MCP 예제 만들기 1

    MCP 예제 프로젝트 생성
    mcp 예제
    신
    신민정
    2025.04.08
    ·
    2 min read

    어제는 이론에 대한 포스팅에 이어 예제 실습을 해보고자 한다.

    공식 문서를 참고로 하여 정리 하고자 한다.

    Java와 Kotlin 둘다 선택 가능 했는데, 이번 예제는 kotlin으로 해보고자 한다.

    [예제가 올라갈 Git hub 정보]

    GitHub - paypulse/mcpDemO
    Contribute to paypulse/mcpDemO development by creating an account on GitHub.
    https://github.com/paypulse/mcpDemO.git
    GitHub - paypulse/mcpDemO

    Project Spec

    1. Java version 17이상 

    뭐인지 모르겠지만, 프로젝트 시작시 intellij에서 MCP Server, Client dependency를 추가 할 수 있게 되어 있다. 일단, 추가 하지 않고 문서 대로 시작 !!

    plugins {
        kotlin("jvm") version "1.9.25"
        kotlin("plugin.spring") version "1.9.25"
        war
        id("org.springframework.boot") version "3.4.4"
        id("io.spring.dependency-management") version "1.1.7"
        kotlin("plugin.jpa") version "1.9.25"
        kotlin("plugin.serialization") version "1.9.25"
        id("com.github.johnrengelman.shadow") version "8.1.1"
    }
    
    group = "com.example"
    version = "0.0.1-SNAPSHOT"
    
    val mcpVersion = "0.4.0"
    val slf4jVersion = "2.9.0"
    val ktorVersion = "3.1.1"
    
    java {
        toolchain {
            languageVersion = JavaLanguageVersion.of(17)
        }
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation("org.springframework.boot:spring-boot-starter-data-jpa")
        implementation("org.springframework.boot:spring-boot-starter-web")
        implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
        implementation("org.jetbrains.kotlin:kotlin-reflect")
    
        // mcp
        implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
        implementation("org.slf4j:slf4j-simple:2.0.9")
        implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
        implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
    
    
        runtimeOnly("com.h2database:h2")
        providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
        testImplementation("org.springframework.boot:spring-boot-starter-test")
        testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
        testRuntimeOnly("org.junit.platform:junit-platform-launcher")
    }
    
    kotlin {
        compilerOptions {
            freeCompilerArgs.addAll("-Xjsr305=strict")
        }
    }
    
    allOpen {
        annotation("jakarta.persistence.Entity")
        annotation("jakarta.persistence.MappedSuperclass")
        annotation("jakarta.persistence.Embeddable")
    }
    
    tasks.withType<Test> {
        useJUnitPlatform()
    }
    

    일단, 오늘은 프로젝트 셋팅 하고 끝. ㅋ


    [출처]

    Introduction - Model Context Protocol
    Get started with the Model Context Protocol (MCP)
    https://modelcontextprotocol.io/introduction
    Introduction - Model Context Protocol